Model Selection Methods and Machine Learning
Predictive Model Selection: From Fit to Forecast
An economist predicting household spending or business sales often has several plausible models. Predictive model selection means choosing a modelling procedure for its expected performance on new observations. Your decision includes which predictors, transformations, and tuning settings to use. The strongest fit to the observations already available need not produce the most accurate predictions elsewhere.
Choose a prediction loss
Start by identifying what you will predict, when the prediction will be issued, and which information will be available then. A variable recorded after the outcome occurs may fit historical data well while being unavailable for the intended prediction.
Choose a loss that matches the decision. For a numerical outcome, mean squared error gives larger mistakes more weight:
Here, yi is the observed outcome, y^i is its prediction, and n is the number of evaluated observations. For held-out evaluation, each prediction comes from a model fitted without that observation. MSE has squared outcome units; root mean squared error, or RMSE, has the outcome's original units.
A model that predicts well does not automatically identify a causal effect. Predictive selection asks how accurately you can forecast an outcome using available information; it does not establish what would happen after a policy intervention.
Keep the data roles separate
A useful design gives observations three distinct roles. Make these assignments before comparing candidate performance.
Sample | Main use | What its error tells you |
|---|---|---|
Training | Estimate each candidate's fitted parameters | How closely it fits observations used for estimation |
Validation | Compare candidates and tuning settings | Which candidate predicts held-out observations better |
Test | Assess the locked choice | How the selected procedure performs on untouched observations |
Additional flexibility can reduce training error by fitting accidental patterns. Validation error may then increase. Consequently, a higher training fit alone is insufficient evidence for choosing a more elaborate model.
Compare candidates with cross-validation
Cross-validation repeatedly fits and evaluates a procedure on different portions of the development data. In K-fold cross-validation, divide these data into K groups. Hold out one group, fit on the others, and predict the held-out group. Repeat until every group has been held out once. Keep the final test sample outside this process.
Use the same folds for competing candidates so differences are not driven by different evaluation observations. For average squared error per observation, combine fold results as
where nk is the number of held-out observations in fold k. Equal-sized folds allow a simple average of fold MSE values. Unequal folds require weighting by their observation counts.
The splitting design should resemble the prediction task. For forecasting, train on earlier periods and validate on later periods. For prediction about entirely new firms, keep a firm's repeated observations together when forming evaluation groups. Random row splits can otherwise create an easier task than the one you intend to solve.
Control flexibility and report honestly
Candidate models can vary predictor subsets, transformations, and hyperparameters. One example is regularization strength. A stronger penalty can improve held-out predictions even when it worsens training fit.
Learn every data-dependent preparation step inside each training split. This includes missing-value replacements, scaling, and predictor selection. Apply the learned preparation to the held-out observations without estimating it again there.
Select using the chosen validation loss, while recognizing that small differences may reflect sampling variation. Searching many candidates also increases the opportunity to find an unusually favourable validation result. After locking the procedure, refit it on the development data and assess it using the untouched test sample. Report the loss, units, and evaluation design.
What to remember:
- Match the loss and data split to the intended prediction task.
- Compare candidates using held-out errors and consistent folds.
- Keep preparation and tuning away from evaluation observations.
- Preserve an untouched test sample for the final assessment.
Example: Predictive Model Selection for Store Sales
A grocery wholesaler predicts weekly sales for independently sampled stores using information available before the sales week. Sales are measured in thousand Canadian dollars, written as thousand CAD. The wholesaler has 120 development stores and 30 separate test stores drawn from the same target population.
Two candidate procedures are compared using the same three development-data folds. Each fold holds out 40 stores and fits the procedure on the other 80. Any data-dependent preparation is learned using those 80 training stores. The cross-validation error is the average squared error across all held-out predictions.
All squared-error quantities in the table use (thousand CAD)2. Mean training MSE is averaged across the three fits.
Candidate | Mean training MSE | Fold 1 held-out SSE | Fold 2 held-out SSE | Fold 3 held-out SSE |
|---|---|---|---|---|
Compact | 8 | 360 | 480 | 600 |
Expanded | 2 | 320 | 640 | 840 |
Here, SSE refers to prediction errors on the indicated held-out fold.
a) Calculate each candidate's cross-validation MSE and select the candidate with the smaller value.
First, add squared errors across the three held-out folds. Compact's total is ________, and Expanded's total is ________, both in (thousand CAD)2.
Each store is predicted once while held out, so the total number of evaluated stores is ________. Divide each total by this count:
Select Compact, with cross-validation MSE 12 (thousand CAD)2. Expanded's lower training MSE does not outweigh its higher held-out error under the specified selection rule.
b) Express the selected candidate's cross-validation performance as RMSE, to two decimal places, and explain its units.
MSE averages squared prediction errors. Taking its square root expresses the score in the original sales units:
The selected candidate's cross-validation RMSE is 3.46 thousand CAD. It summarizes the size of held-out prediction errors using squared-error weighting; it is not the mean absolute error or a guarantee about every store's prediction.
c) The wholesaler locks Compact's procedure and refits it on all 120 development stores. Its SSE on the 30 untouched test stores is 480 (thousand CAD)2. Calculate the test RMSE to two decimal places and state whether this score should be used to retune the model.
The test observations have not contributed to fitting or selection. Their average squared prediction error is ________ in (thousand CAD)2:
Taking the square root gives
The final test RMSE is 4.00 thousand CAD. It differs from the cross-validation RMSE because it evaluates a refitted model on different stores. That difference alone does not establish a change in the sales-generating process.
Using this test score to retune would make it part of selection. Report it as the final assessment of the locked procedure; evaluating a revision as untouched would require fresh evaluation observations.
An economist is comparing five methods for predicting household expenditure from a common set of candidate predictors. Match each method to its defining procedure. Assume squared-error fitting, with the intercept excluded from coefficient penalties.
Starts with an intercept-only model and repeatedly adds the remaining predictor that most improves a specified criterion.
Adds a penalty proportional to the sum of absolute predictor coefficients.
Combines penalties on absolute predictor coefficients and squared predictor coefficients.
Adds a penalty proportional to the sum of squared predictor coefficients.
Searches all predictor subsets under consideration and chooses using a specified criterion.
Lasso regression
Best subset selection
Elastic net
Forward stepwise selection
Ridge regression
A retailer predicts next week's number of online orders for independently sampled shops using information available before that week. A three-fold validation design has unequal held-out fold sizes. Each shop is held out exactly once, and its prediction is obtained without fitting on that shop.
Held-out fold | Number of shops | Sum of squared prediction errors (orders squared) |
|---|---|---|
1 | 20 | 450 |
2 | 30 | 900 |
3 | 50 | 1650 |
Calculate the pooled root mean squared prediction error, giving each shop equal weight. Answer in orders, to two decimal places.