The process of validating machine learning models involves carefully designed steps to ensure that the models we create perform well not just on the data they were trained on, but also on new, unseen data. This is critical because the true test of a machine learning model is its ability to generalize from its training data to new instances. The explanation below will delve into two main aims of validation: model selection and model assessment.
Model Selection
Model selection is the process of choosing the best model from among a set of candidate models. This is a critical step to ensure that the model we eventually use is the one that best captures the underlying patterns in the data, without overfitting (memorizing the training data) or underfitting (failing to capture the underlying patterns).
- Hyper-parameter Tuning: One important aspect of model selection is finding the optimal settings (hyper-parameters) for your model. For example, in a polynomial regression model, the degree of the polynomial is a hyper-parameter. In ridge regression, the regularization strength (lambda) is a hyper-parameter. Tuning these hyper-parameters involves searching for the values that result in the best performance of the model.
- Generalization Error Estimation: The aim during model selection is to estimate the generalization error of different models. The generalization error is a measure of how well a model performs on unseen data. To estimate this, we often use techniques like cross-validation, where the training data is split into smaller train and validation sets. The model is trained on the smaller train set and validated on the validation set, and this process is repeated multiple times with different splits to get a reliable estimate of generalization error.
Model Assessment
Once we have selected the best model through the model selection process, the next step is model assessment. This is where we evaluate the performance of our chosen model on a completely new set of data, often called the test set, which the model has never seen before.
- Generalization Error on New Data: The purpose of model assessment is to get an unbiased estimate of the generalization error of our chosen model when it is applied to new data. This gives us a sense of how well the model is expected to perform in the real world.
- Estimation, not Selection: It's important to note that during model assessment, we are not looking to make further tweaks or changes to our model based on its performance on the test set. The aim is purely to estimate its generalization error. Making adjustments based on the test set performance without additional validation can lead to overfitting on the test set.
The Golden Rule: Separation
A golden rule in model validation is to clearly keep the processes of model selection and model assessment separate. This means using separate datasets for each phase. Typically, one would use:
- Training data for fitting the models,
- Validation data (or cross-validation techniques) for model selection and hyper-parameter tuning,
- Test data for the final model assessment.
The separation ensures that we get an unbiased estimate of how our model is likely to perform on completely unseen data, which is the ultimate test of its usefulness.
In summary, the process of validating machine learning models through model selection and model assessment is crucial for developing models that are not just theoretically sound but practical and reliable for making predictions on new data.