Machine Learning Modelling in R Cheat Sheet
An R modelling reference for data splits, recipe preprocessing, model specifications, workflows, resampling, tuning and final evaluation.
What this reference covers
This reference turns an R modelling project into a sequence of data splitting, recipe preprocessing, model specification, workflow, resampling, tuning and final evaluation. It is useful for building a reproducible experiment and for changing algorithms without losing the validation boundary.
Put preprocessing inside the training boundary
Fix the target, prediction time, strata and test set before fitting a recipe. Missing-value imputation, scaling, dummy encoding and feature selection should be estimated inside each training fold so validation and test data do not influence the learned rules.
Tune, lock and test once
Use resampling to compare candidates and parameters. After selecting a final workflow, lock the choices and evaluate on an independent test set. Record metrics, error examples, random seed, data version, resource cost and model version rather than keeping only the best score.
Maintenance note
Resampling does not replace checks for time order, repeated subjects, imbalance, drift, privacy or domain validity. High performance is not evidence of causality or production safety. Content review date: 2026-08-23.
Save to your cloud drive
Save the complete collection first so files remain together and are easier to access across devices.
Quark Cloud Drive
RecommendedSave Machine Learning Modelling in R Cheat Sheet to this cloud drive
Baidu Netdisk
Save Machine Learning Modelling in R Cheat Sheet to this cloud drive
R machine learning modelling study guide
Fix the task and data split, fit preprocessing within the training boundary, compare workflows with resampling and reserve the test set for the final check.
Before you start
- Prepare a PDF reader and a labelled data set with basic quality checks.
- Understand features, targets, train, validation, test and resampling.
- Write down the prediction time and any grouping or temporal boundary.
Quick start
- 01
Define task and split
Choose classification, regression or another task, set the target, strata, time boundary and independent test set before modelling.
- 02
Build a preprocessing recipe
Put imputation, scaling, dummy encoding and feature selection inside the training workflow so validation and test data only receive learned rules.
- 03
Compose and compare workflows
Bind a recipe to a model specification, run a simple baseline and compare algorithms, parameters and resampling strategies.
- 04
Tune and evaluate finally
Use resampling for selection, lock the final plan and report metrics and error examples once on the untouched test set.
Usage tips
- Estimate preprocessing separately inside every training fold to reduce leakage.
- For imbalanced classification, inspect recall, precision, specificity or PR curves instead of accuracy alone.
- Record seed, split, recipe, parameters, metrics and model version for reproduction.
Troubleshooting and uninstall
Why are resampling metrics unstable?
Check sample size, class distribution, stratification and duplicate records, and diagnose the resampling distribution instead of selecting one unusually high result.
Why is test performance much worse than validation?
Check indirect test tuning, preprocessing boundaries, time drift and distribution changes, then return to a fixed baseline.
Frequently asked questions
What does this R modelling cheat sheet cover?
It covers data splits, recipe preprocessing, model specifications, workflows, resampling, tuning, metrics and final test evaluation.
Why put preprocessing in a recipe?
The workflow can estimate transformations within each training fold, reducing the chance that validation or test information leaks into the model.
How do validation and test sets differ?
Validation data can guide selection and tuning, while the test set should remain independent until the final locked evaluation.
Is one evaluation metric enough?
Usually not. Choose complementary metrics based on task, class balance, error costs and uncertainty, and inspect representative errors.