R1 Part 2: Regularised Feature Selection & Predictive ML Benchmarking
Mohammad Abbas
2026-11-30
Purpose of R1 Part 2
R1 Part 1 established interpretable models of aerobic demand and rested status using derived physiological variables within the sportsfeatures framework. The Decomposed Multiple Linear Regression Model explained approximately 76.5% of the observed variation in aerobic demand, providing a benchmark for further predictive analysis. R1 Part 2 extends this work through regularised feature selection and out-of-sample predictive evaluation. LASSO and Elastic Net assess predictor retention, while Random Forest provides a non-linear comparison of predictive performance.
Why Machine Learning?
Traditional regression models provide interpretable estimates of physiological relationships and support our understanding in data modelling. Within the sportsfeatures context, as the number of derived variables increases, correlated predictors and non-linear relationships can make modelling more challenging. Machine-learning approaches offer alternative ways to address these challenges. LASSO and Elastic Net support regularised feature selection, while Random Forest addresses non-linear relationships and interactions without requiring them to be specified explicitly. These methods allow predictive performance to be evaluated beyond the statistical benchmarks established in R1 Part 1.
Why LASSO, Elastic Net and Random Forest?
This vignette uses three complementary modelling approaches to explore feature selection and predictive performance. Each provides a different perspective on predictor selection, model complexity, and out-of-sample performance. LASSO applies an L1 penalty that progressively shrinks coefficient estimates towards zero as the penalty increases. This allows a smaller set of predictors to be identified from the wider collection of physiological, session-level, and contextual features. Elastic Net combines L1 and L2 penalties, retaining the feature-selection properties of LASSO while allowing correlated predictors to remain represented in the fitted model. Random Forest provides a contrasting non-linear approach without estimating a penalised linear coefficient structure. It uses an ensemble of decision trees to represent more complex relationships among predictors.
MODEL 04: LASSO and Elastic Net Feature Selection
Model Overview
Unlike the models examined in the preceding vignette, Model 04 applies regularised feature selection. LASSO and Elastic Net apply coefficient penalties that can shrink predictor estimates towards zero during model fitting.
Model Family: Penalised linear regression (glmnet)
Dependent Variable (Y): vo2_utilisation
LASSO Specification:α = 1
Elastic Net Specification:α = 0.5
Penalty Selection: 10-fold cross-validation
Primary Selection Criterion:lambda.1se
Predictor Representation: Standardised numeric predictors and dummy-coded categorical contrasts
Hypothesis and Intent
Hypothesis: A regularised regression framework can identify a simpler subset of physiological, session-level, activity-related, and contextual predictors of VO₂ utilisation by shrinking less informative coefficient estimates towards zero.
Intent: Using a common predictor matrix and cross-validated penalty selection, the analysis compares LASSO and Elastic Net to identify which predictors remain active under regularisation. Model 05 subsequently evaluates predictive performance.
Mathematical Formulation
For observations i = 1, …, N, the Elastic Net objective can be written as
Here, λ controls the overall strength of regularisation and α determines the balance between L1 and L2 penalties. Setting α = 1 produces the LASSO specification, whereas α = 0.5 produces the Elastic Net specification used in this analysis. Cross-validation is used to select the penalty parameter, with lambda.1se providing the more parsimonious cross-validated solution used for coefficient inspection.
Retained activity-group contrast relative to the model-matrix reference level.
activity_groupWalking
−0.01270
Retained activity-group contrast relative to the model-matrix reference level.
weather_groupOther
+0.00434
Retained weather-group contrast with a small positive coefficient.
weather_groupOvercast
−0.00037
Retained, but strongly shrunk towards zero.
weather_groupRain
+0.00624
Retained weather-group contrast with a small positive coefficient.
personal_statusOptimal
−0.00305
Retained personal-status contrast with a small negative coefficient.
personal_statusPoor sleep
−0.00466
Retained personal-status contrast with a small negative coefficient.
personal_statusTired
−0.00346
Retained personal-status contrast with a small negative coefficient.
Cross-Validation Profiles for LASSO and Elastic Net
# Cross-Validation Profiles for LASSO and Elastic Netpar(mfrow =c(1, 2))plot(cv_lasso, main ="LASSO (alpha = 1)")plot(cv_enet, main ="Elastic Net (alpha = 0.5)")
Figure 4.1. Cross-validation error profiles across the LASSO and Elastic Net penalty paths.
par(mfrow =c(1, 1))
Key Findings and Analytical Insight
Regularised coefficient retention: At lambda.1se, both LASSO and Elastic Net retain non-zero coefficients across physiological, session-level, activity-related, weather, and personal-status predictors. The retained coefficients suggest that predictive information is spread across several feature groups rather than confined to one.
Pace-related predictors:pace_centered and athlete_mean_pace retain negative coefficients in the Elastic Net specification (β = −0.0146 and β = −0.0211, respectively), retaining both within-athlete pace deviation and athlete-level mean pace within the penalised model.
Distance and activity contrasts:distance_centered retains a small positive coefficient (β = +0.00107), while the Running and Walking activity contrasts remain non-zero (β = +0.0539 and β = −0.0127, respectively).
Strongly shrunk coefficients: Age (β = −0.00011) and the Overcast weather contrast (β = −0.00037) remain non-zero but are strongly shrunk towards zero at the selected Elastic Net penalty. These estimates should be interpreted as weak contributors within the penalised coefficient structure rather than as evidence of statistical non-significance.
LASSO and Elastic Net comparison: The two regularisation specifications produce broadly similar retained feature structures, while Elastic Net retains one additional non-zero term at lambda.1se. Their predictive performance is evaluated separately in Model 05 rather than inferred from coefficient retention alone.
Key Summary Statistics
The visual summary below brings together the main Model 04 results: the LASSO and Elastic Net penalty specifications, the cross-validated lambda.1se solutions, and selected retained or strongly shrunk coefficients.
Figure 4.2. Key regularisation settings and selected coefficient patterns from the LASSO and Elastic Net models.
From Model 04 to Model 05: Feature Selection to Predictive Generalisation
As feature selection and retention do not establish predictive performance, Model 05 evaluates OLS, Elastic Net, and Random Forest using a common train-test split to compare predictive performance on held-out observations.
MODEL 05: Out-of-Sample Predictive Benchmarking
Model Overview
This model focuses on predictive evaluation through held-out observations. A common predictor specification is used to compare three modelling approaches: ordinary least-squares regression, Elastic Net regression, and Random Forest regression.
The available observations are divided into an 80% training subset and a 20% test subset. Each model is fitted using the training data, and predictive performance is then evaluated against the observed vo2_utilisation values in the held-out test data.
Outcome Variable (Y): vo2_utilisation
Compared Models: Ordinary Least Squares, Elastic Net, and Random Forest regression
Data Partition: Random 80/20 train-test split
Training Observations:N = 322
Test Observations:N = 81
Evaluation Metrics: RMSE, MAE, and out-of-sample R2
Random Forest Specification: 500 trees using ranger
Hypothesis and Intent
Hypothesis: Predictive performance on the held-out test subset may differ across linear, regularised linear, and non-linear ensemble approaches because the models represent predictor relationships with different levels of flexibility.
Intent: The analysis compares Ordinary Least Squares, Elastic Net, and Random Forest regression using a common random train-test partition. Performance is evaluated using Root Mean Squared Error, Mean Absolute Error, and out-of-sample R2. The objective is to identify which model predicts the held-out observations best within this data split.
Out-of-Sample Evaluation Metrics
For a test subset containing ntest observations, predictive error is evaluated using Root Mean Squared Error:
Lower RMSE and MAE values indicate smaller prediction errors, while a higher out-of-sample R2 indicates that the fitted predictions account for a greater proportion of variation in the held-out outcome values.
Prepare Row-Level Data for Out-of-Sample Evaluation
# Create only variables that can be calculated independently for each row.# Athlete means and centred predictors are intentionally not calculated here.df_ml_base <- df_sports %>%mutate(pace_min_km =round(duration_min / distance_km, 2),activity_group =factor(case_when(str_detect( activity_type,regex("cycle|bike", ignore_case =TRUE) ) ~"Cycling",str_detect( activity_type,regex("walk", ignore_case =TRUE) ) ~"Walking",str_detect( activity_type,regex("hiking", ignore_case =TRUE) ) ~"Hiking",str_detect( activity_type,regex("run|jog", ignore_case =TRUE) ) ~"Running",TRUE~"Other" ) ),weather_group =factor(case_when(str_detect( weather_type,regex("cloud", ignore_case =TRUE) ) ~"Cloudy",str_detect( weather_type,regex("overcast", ignore_case =TRUE) ) ~"Overcast",str_detect( weather_type,regex("rain|shower", ignore_case =TRUE) ) ~"Rain",str_detect( weather_type,regex("sun|clear", ignore_case =TRUE) ) ~"Sunny",TRUE~"Other" ) ),personal_status =factor(str_replace_all(str_to_title(personal_status),"_"," " ) ) ) %>%filter(!is.na(vo2_utilisation),!is.na(athlete_id),!is.na(distance_km),!is.na(pace_min_km),!is.na(fatigue_score),!is.na(calories_per_min),!is.na(activity_group),!is.na(weather_group),!is.na(personal_status) )
Generate an 80/20 Random Train-Test Split
set.seed(123)train_indices <-sample(seq_len(nrow(df_ml_base)),size =floor(0.8*nrow(df_ml_base)))train_base <- df_ml_base[train_indices, , drop =FALSE]test_base <- df_ml_base[-train_indices, , drop =FALSE]cat("--- DATA SPLIT SUMMARY ---\n")
--- DATA SPLIT SUMMARY ---
cat("Training Set Rows:", nrow(train_base), "\n")
Training Set Rows: 322
cat("Testing Set Rows :", nrow(test_base), "\n\n")
Figure 5.1. Observed and predicted VO₂ utilisation for the three models in the held-out test subset.
Interpretation of Observed and Predicted VO₂ Utilisation in the Test Subset
The dashed identity line represents exact agreement between observed and predicted VO₂ utilisation. Predictions closer to this line indicate smaller errors for the corresponding test observations.
The Random Forest panel shows closer overall alignment with the identity line than the OLS and Elastic Net panels, consistent with its lower RMSE and MAE and higher out-of-sample R2. The OLS and Elastic Net predictions are more concentrated around the middle of the outcome range, while the lower and upper ends are represented less well.
These patterns describe performance on the current held-out test subset. Since the analysis uses one random row-level split, Figure 5.1 does not establish generalisation to new athletes, future sessions, or repeated resamples.
Key Findings and Analytical Insight
Random Forest performance: Random Forest achieves the lowest test RMSE (0.0371) and MAE (0.0278), together with the highest out-of-sample R2 (0.796), among the three models evaluated on the held-out subset.
OLS benchmark: The OLS model achieves a test RMSE of 0.0513, MAE of 0.0398, and out-of-sample R2 of 0.611. It performs better than Elastic Net within this split but does not match the Random Forest test metrics.
Elastic Net performance: This produces a test RMSE of 0.0552, MAE of 0.0426, and out-of-sample R2 of 0.549. Its regularised coefficient structure does not translate into improved test-set accuracy relative to OLS in this comparison.
Interpretation of the benchmark: Within this held-out subset, Random Forest provides stronger predictive performance than OLS and Elastic Net. In the absence of further modelling, this analysis does not establish which specific non-linearities or interactions account for that improvement.
Key Summary Statistics
The following visual summary compares the principal out-of-sample performance metrics across OLS, Elastic Net, and Random Forest regression.
Figure 5.2. Out-of-sample performance metrics for OLS, Elastic Net, and Random Forest regression.
Concluding Remarks
This part of the vignette extended the traditional modelling approaches given in the preceding part through regularised feature selection and out-of-sample predictive benchmarking. Model 04 examined LASSO and Elastic Net regularisation, while Model 05 compared predictive performance on a held-out test subset.
The regularisation analysis, Model 04, showed that LASSO and Elastic Net retained non-zero coefficients across several feature groups. Pace-related predictors, centred session distance, activity-group contrasts, and selected contextual variables remained represented at the cross-validated lambda.1se solutions, while some coefficients were strongly shrunk towards zero. Regularisation provided a simpler representation of the candidate predictor structure without requiring all coefficients to contribute equally.
The out-of-sample benchmarking analysis compared Ordinary Least Squares, Elastic Net, and Random Forest regression using a common random 80/20 train-test split. Within this split, Random Forest produced the lowest test RMSE (0.0371) and MAE (0.0278), together with the highest out-of-sample R2 (0.796). OLS achieved an out-of-sample R2 of 0.611, while Elastic Net achieved 0.549. Random Forest appeared to provide the strongest predictive performance among the three models on the held-out observations used in this analysis.
Both parts of the R1 vignette provided complementary modelling perspectives on prediction within the sportsfeatures framework. Part 1 demonstrated interpretable statistical models for aerobic demand and rested status, whereas Part 2 explored regularised feature selection and comparative predictive performance on held-out observations. The R2 values reported should be interpreted in their respective evaluation contexts: the benchmark multiple-regression output describes in-sample model fit, whereas the Model 05 results describe performance on a held-out test subset.
The R1 vignette provides a foundation for moving from prediction towards explanation. R2 extends this work through hierarchical and mixed-effects modelling of physiological variation.