Development version
You are reading the latest (development) docs. For stable documentation, see stable.
Hyperparameter Tuning Recipes
Recipes are short, copy-paste ready solutions to specific problems. Each recipe answers exactly one question — run it, adapt it, move on.
Recipes vs Tutorials vs Examples
| Recipes | Tutorials | Examples | |
|---|---|---|---|
| Purpose | Solve one specific problem | End-to-end conceptual walkthrough | Demonstrate a library feature |
| Length | 5–10 min | 20–40 min | 5–15 min |
| Code | Copy-paste ready | Guided walkthrough | Feature-focused snippet |
Classification
| Recipe | What it solves |
|---|---|
| Tune RandomForestClassifier | 7-parameter joint search with class_weight |
| Tune LogisticRegression | Solver/penalty compatibility, multi-class |
| Tune SVC | C/gamma with mandatory scaling in a Pipeline |
| Tune XGBClassifier | 9 params, CPU oversubscription fix, n_jobs=1 |
| Tune LGBMClassifier | num_leaves/max_depth interaction |
| Tune CatBoostClassifier | Categorical columns, bagging_temperature |
| Tune HistGradientBoostingClassifier | Fast sklearn GBM, max_leaf_nodes |
| Tune ExtraTreesClassifier | High variance vs RF, max_features |
Regression
| Recipe | What it solves |
|---|---|
| Tune RandomForestRegressor | min_samples_leaf vs min_samples_split, MAE scoring |
| Tune XGBRegressor | Regression with custom eval_metric |
| Tune LGBMRegressor | RMSE scoring, min_child_samples |
| Tune CatBoostRegressor | Regression with ordered boosting |
| Tune ElasticNet | l1_ratio/alpha interaction, log-uniform |
Feature Selection
| Recipe | What it solves |
|---|---|
| Select Features on 50+ Columns | Threshold strategy for large feature sets |
| Combine Feature Selection + Hyperparameter Tuning | Two-stage: select features, then retune |
| Use a Custom Scorer for Feature Selection | Wrap roc_auc with a feature-count penalty |
| Feature Selection with Cross-Validation | Per-fold selection to avoid leakage |
Pipelines
| Recipe | What it solves |
|---|---|
| Tune a Preprocessing + Estimator Pipeline | StandardScaler + SVC with step prefix |
| Tune a ColumnTransformer Pipeline | Mixed types, preprocessor__... param paths |
| Tune Imputer Strategy as a Hyperparameter | Search over mean/median/most_frequent |
| Tune Polynomial Features Degree | Include degree and interaction-only as params |
Scoring Metrics
| Recipe | What it solves |
|---|---|
| Tune for F1 Score (Binary) | scoring="f1", thresholds, confusion matrix |
| Tune for ROC-AUC | scoring="roc_auc", probability calibration |
| Tune for Balanced Accuracy | Class imbalance, class_weight as a param |
| Tune for MAE (Regression) | scoring="neg_mean_absolute_error" |
| Tune for RMSE (Regression) | Custom neg_root_mean_squared_error scorer |
Integrations
| Recipe | What it solves |
|---|---|
| Log Every Candidate to MLflow | MlflowCallback, nested runs, param logging |
| Parallelize with Joblib | n_jobs, loky vs threading backend |
| Run in a Jupyter Notebook | verbose=True, tqdm progress, plot inline |
Advanced
| Recipe | What it solves |
|---|---|
| Seed a Search with Known-Good Params | warm_start_configs to skip cold start |
| Stop Early When Fitness Plateaus | ConsecutiveStopping callback setup |
| Stop After a Time Budget | TimerStopping for wall-clock limits |
| Resume a Stopped Search | Save/load state, continue from checkpoint |
| Write a Custom Scoring Function | make_scorer + unsupervised metrics |
See Also
- Tutorials — end-to-end model walkthroughs with explanations
- Examples — focused library feature demonstrations
- API Reference — full parameter documentation
- Common Mistakes — pitfalls to avoid
