Troubleshooting¶
Solutions to common problems when using Sklearn-Optuna.
Installation Issues¶
- Problem: Package not found
- Verify the package name:
pip install sklearn-optunaoruv add sklearn-optuna. - Problem: Import error after installation
- Make sure you installed in the active environment:
python -c "import sklearn_optuna". - Problem: Optuna version conflict
- Sklearn-Optuna requires Optuna 3.5-3.x. If you have Optuna 4.x installed, downgrade with
pip install "optuna>=3.5,<4".
Search Issues¶
- Problem: Results are not reproducible
- Wrap the sampler with
Samplerand passseed=. Usen_jobs=1because parallel trial ordering is non-deterministic. See How to Configure Samplers. - Problem: All trials return NaN
- The estimator may be failing silently. Set
error_score="raise"to surface the underlying error. See How to Handle Errors. - Problem: Search is slow
- Reduce
n_trialsor set atimeoutto cap execution time. Check thatcvis not set to a large number of folds. Consider usingn_jobs=-1for parallel trial execution on a single machine, or distribute trials across multiple nodes with a shared database storage (see Concepts: Multi-node optimization). - Problem: CMA-ES sampler raises an error
- CMA-ES does not support
CategoricalDistributionparameters. UseTPESamplerfor mixed search spaces.
Pipeline Issues¶
- Problem: Parameter not found in pipeline
- Use double-underscore syntax to address nested parameters:
"clf__C"for theCparameter of theclfstep. See How to Use in Pipelines. - Problem: OptunaSearchCV does not work as a pipeline step
OptunaSearchCVis a valid Scikit-Learn estimator and works as a pipeline step. Make sure you pass it as a step tuple:("search", search).
Storage Issues¶
- Problem: Study not resuming from database
- Make sure you use the same
study_nameandStorageconfiguration. See How to Persist and Resume Studies.