Preprocessing can change values, encode predictors, or select rows and columns. General data preparation and model-fitted transformations have different roles in an analysis.
8.1 Prepare data
setup_Preprocessor() configures standalone preprocessing. preprocess() returns a Preprocessor; preprocessed() extracts its data.
2026-10-25 14:46:56 Imputing missing values using the mean (numeric) and mode (categorical)... [preprocess_data]2026-10-25 14:46:56 Scaling and centering 4 numeric features... [preprocess_data]2026-10-25 14:46:56 Preprocessing done. [preprocess_data]
2026-10-25 14:46:56 Imputing missing values using the mean (numeric) and mode (categorical)... [preprocess_data]2026-10-25 14:46:56 Scaling and centering 4 numeric features... [preprocess_data]2026-10-25 14:46:56 Preprocessing done. [preprocess_data]
The fitted configuration contains learned centers, scales, or encodings. Factor encodings follow the training levels.
8.3 Preprocess within model training
Data-dependent transformations belong inside the training procedure when estimating predictive performance. setup_SupervisedPreprocessor() describes transformations that preserve case alignment and the supervised feature contract. train() fits these operations within the relevant training splits and applies the fitted operations to validation and assessment data.
2026-10-25 14:46:56 Checking data is ready for training... ✔ [check_supervised]
2026-10-25 14:46:56 ▶ [train]2026-10-25 14:46:56 Training set: 150 cases x 4 features. [summarize_supervised]2026-10-25 14:46:56 //CPU | serial | 1 worker: algorithm 1 thread, tuning 1, outer resampling 1 [msg_resources]2026-10-25 14:46:56 Shared memory (auto): not sharing training data (7.3 kB) -- this run transfers nothing to workers. [report_shared_memory]2026-10-25 14:46:56 <> Training CART Classification using 3 independent folds... [train]2026-10-25 14:46:56 ✔ Outer resamples 3/3 done in 0:00
2026-10-25 14:46:56 </> Outer resampling done. [train]
<Resampled Classification Model>CART (CART decision tree (rpart))
▣ Preprocessed using centering, scaling.
⟳ Tested using 3 independent folds.
<Resampled Classification Training Metrics>Aggregate Confusion Matrix across resamples.
Predicted Referencesetosa versicolor virginica setosa 100 0 0
versicolor 0 98 2
virginica 0 1 99
Showing mean (sd) across resamples.
Balanced Accuracy: 0.990 (0.010) F1: 0.990 (0.010) Accuracy: 0.990 (0.010)<Resampled Classification Test Metrics>Aggregate Confusion Matrix across resamples.
Predicted Referencesetosa versicolor virginica setosa 50 0 0
versicolor 0 48 2
virginica 0 5 45
Showing mean (sd) across resamples.
Balanced Accuracy: 0.953 (0.030) F1: 0.953 (0.030) Accuracy: 0.953 (0.030)
2026-10-25 14:46:56 Done in 0.44 seconds. [train]
Supported operations include imputation, missingness indicators, type conversion, one-hot encoding, scaling, and date features. Their applicability depends on the data and learner. Resolve record duplication and study-specific exclusions before defining resamples; preserve the exclusion criteria in the analysis record.
A decomposition_config adds a fitted dimensionality-reduction step to train(). That decomposition must support application to new cases; see decomposition.