Skip to content

Tune Hyperparameters

Hyperparameter tuning finds the optimal settings for your model. MLOps Desktop integrates Optuna for intelligent hyperparameter search with three strategies: Bayesian (TPE), Random, and Grid.

Time to complete: ~15 minutes

  • Completed the Quickstart tutorial
  • Python packages: pip install optuna
  1. Open your pipeline

    Load a pipeline with DataLoader → DataSplit → Trainer → Evaluator.

  2. Select Tune mode

    Click the Trainer node. At the top of the node, click the Tune button (next to Train and Load).

  3. Configure model and target

    • Model Type: Select any model except Linear Regression (no tunable params)
    • Target Column: Your target variable
  4. Open Tuning Configuration

    Click the Configure Tuning button to open the TuningPanel.

  5. Set tuning parameters

    SettingRecommendedRange
    Search StrategyBayesian (TPE)TPE, Random, Grid
    Number of Trials501-1000
    CV Folds32-10
    Scoring Metricaccuracy (classification) or r2 (regression)varies
  6. Run the pipeline

    Click Run. Watch the Trials tab for real-time results.

Tree-structured Parzen Estimator — Default and recommended.

  • Learns from previous trials to focus on promising regions
  • Most efficient for complex search spaces
  • Better results with fewer trials
Trial 1-10: Exploration (random-ish)
Trial 11+: Exploitation (focuses on good regions)

Each model has predefined search ranges optimized for common use cases:

ParameterRangeType
n_estimators50-300 (step 50)Integer
max_depth[None, 10, 15, 20, 30]Categorical
min_samples_split2-10 (step 2)Integer
min_samples_leaf1-4 (step 1)Integer
ParameterRangeType
n_estimators50-300 (step 50)Integer
learning_rate0.01-0.3Log-uniform
max_depth3-8 (step 1)Integer
subsample0.7-1.0Uniform
ParameterRangeType
C0.1-100Log-uniform
kernel[rbf, linear, poly]Categorical
gamma[scale, auto]Categorical
ParameterRangeType
n_neighbors3-21 (step 2)Integer
weights[uniform, distance]Categorical
metric[euclidean, manhattan, minkowski]Categorical
ParameterRangeType
hidden_layer_sizes[(50,), (100,), (100,50), (100,100)]Categorical
alpha0.0001-0.1Log-uniform
learning_rate_init0.0001-0.1Log-uniform
max_iter200-1000 (step 100)Integer
ParameterRangeType
C0.01-100Log-uniform
max_iter500-2000 (step 500)Integer

Choose the metric to optimize:

Classification:

MetricBest For
accuracyBalanced classes (default)
f1Imbalanced classes
precisionMinimize false positives
recallMinimize false negatives
roc_aucRanking quality

Regression:

MetricBest For
r2Overall fit (default)
neg_msePenalize large errors
neg_maeRobust to outliers
neg_rmseSame units as target

During tuning, the Trials tab shows real-time results:

ColumnDescription
#Trial number
ScoreCross-validation score (higher = better)
ParametersHyperparameter values tried
DurationTime for this trial
StatusComplete, Pruned, or Failed

The best trial is highlighted with a star icon.

Trial 1: 0.823 n_estimators=150, max_depth=10 2.1s
Trial 2: 0.845 n_estimators=200, max_depth=15 2.8s
Trial 3: 0.831 n_estimators=100, max_depth=None 1.9s
...
★ Trial 17: 0.867 n_estimators=250, max_depth=20 3.2s ← Best

Tuning uses k-fold cross-validation (not a simple train/test split):

  1. Training data split into k folds
  2. Model trained k times, each time validating on a different fold
  3. Scores averaged for final trial score

This provides more reliable scoring than a single split.

CV FoldsTrade-off
2Fast, high variance
3Good balance (default)
5More reliable, slower
10Most reliable, slowest

When tuning completes:

  1. Best parameters are displayed in the Trials tab
  2. Final model is trained on full training data with best params
  3. Evaluator receives the tuned model for metrics

The best configuration is automatically applied—no manual copying needed.

Begin with 20-30 trials to understand the landscape:

Trial 1-30: Quick exploration
→ Review results
→ Narrow search space if needed
→ Run 50-100 more trials

Bayesian (TPE) outperforms Random search in almost all scenarios. Only use Grid when:

  • You have a very small search space
  • You need exhaustive coverage

With fewer than 1,000 samples, use 5-fold CV to get reliable scores.

If tuning score is much higher than evaluation score, your model may be overfitting to the validation folds. Try:

  • Simpler model (fewer estimators, shallower trees)
  • More regularization (C for SVM, alpha for MLP)
Terminal window
pip install optuna

Linear Regression has no hyperparameters. Use Ridge, Lasso, or another model.

  • Reduce number of trials (20-30 for quick tests)
  • Use Random instead of Grid search
  • Reduce CV folds to 2
  • Use a simpler model (Logistic Regression vs MLP)

If Grid search shows “>10,000 combinations”, the search space is too large. Switch to TPE or Random.