Skip to content

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

RecipesTutorialsExamples
PurposeSolve one specific problemEnd-to-end conceptual walkthroughDemonstrate a library feature
Length5–10 min20–40 min5–15 min
CodeCopy-paste readyGuided walkthroughFeature-focused snippet

Classification ​

RecipeWhat it solves
Tune RandomForestClassifier7-parameter joint search with class_weight
Tune LogisticRegressionSolver/penalty compatibility, multi-class
Tune SVCC/gamma with mandatory scaling in a Pipeline
Tune XGBClassifier9 params, CPU oversubscription fix, n_jobs=1
Tune LGBMClassifiernum_leaves/max_depth interaction
Tune CatBoostClassifierCategorical columns, bagging_temperature
Tune HistGradientBoostingClassifierSample max_leaf_nodes on a log scale for histogram gradient boosting
Tune ExtraTreesClassifierHigh variance vs RF, max_features

Regression ​

RecipeWhat it solves
Tune RandomForestRegressorTune forest smoothness with log-uniform min_samples_leaf and MAE scoring
Tune XGBRegressorRegression with custom eval_metric
Tune LGBMRegressorRMSE scoring, min_child_samples
Tune CatBoostRegressorRegression with ordered boosting
Tune SGDRegressorTune the learning rate and a log-uniform epoch cap inside a pipeline
Tune ElasticNetl1_ratio/alpha interaction, log-uniform

Feature Selection ​

RecipeWhat it solves
Select Features on 50+ ColumnsThreshold strategy for large feature sets
Tune a Pipeline for Each Feature SubsetSelect named DataFrame columns and tune a ridge pipeline inside each training fold
Combine Feature Selection + Hyperparameter TuningTwo-stage: select features, then retune
Use a Custom Scorer for Feature SelectionWrap roc_auc with a feature-count penalty
Feature Selection with Cross-ValidationPer-fold selection to avoid leakage

Pipelines ​

RecipeWhat it solves
Tune a Preprocessing + Estimator PipelineStandardScaler + SVC with step prefix
Tune a ColumnTransformer PipelineMixed types, preprocessor__... param paths
Tune Imputer Strategy as a HyperparameterSearch over mean/median/most_frequent
Tune Polynomial Features DegreeInclude degree and interaction-only as params

Scoring Metrics ​

RecipeWhat it solves
Tune for F1 Score (Binary)scoring="f1", thresholds, confusion matrix
Tune for ROC-AUCscoring="roc_auc", probability calibration
Tune for Balanced AccuracyClass 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 ​

RecipeWhat it solves
Log Every Candidate to MLflowMLflowConfig, nested runs, candidate parameters
Parallelize with Joblibn_jobs, loky vs threading backend
Run in a Jupyter Notebookverbose=True, tqdm progress, plot inline

Advanced ​

RecipeWhat it solves
Compare Integer Search DistributionsCompare uniform and log-uniform sampling at a fixed evaluation budget
Seed a Search with Known-Good Paramswarm_start_configs to skip cold start
Stop Early When Fitness PlateausConsecutiveStopping callback setup
Stop After a Time BudgetTimerStopping for wall-clock limits
Resume a Stopped SearchSave/load state, continue from checkpoint
Write a Custom Scoring Functionmake_scorer + unsupervised metrics

See Also ​

Released under the MIT License.