Troubleshooting¶
Solutions to common problems when using Yohou-Optuna.
Installation Issues¶
- Problem: Package not found
- Verify the package name:
pip install yohou_optunaoruv add yohou_optuna. - Problem: Import error after installation
- Make sure you installed in the active environment:
python -c "import yohou_optuna; print(yohou_optuna.__version__)"
Search Issues¶
- Problem:
AttributeError: 'TPESampler' object has no attribute 'instantiate' - You passed a raw Optuna object instead of a wrapper. Replace
sampler=optuna.samplers.TPESampler()withsampler=Sampler(sampler=optuna.samplers.TPESampler). The same applies toStorageandCallback. See Configure OptunaSearchCV. - Problem:
TypeError: callbacks must be a dict of str to Callback - You passed
callbacksas a list instead of a dictionary. This error appears atfit()time, not at construction. Replacecallbacks=[Callback(...)]withcallbacks={"name": Callback(...)}. The dictionary keys are arbitrary names used for parameter routing. - Problem:
ValueError: scoring parameter cannot be None - The
scoringparameter is required. Pass a scorer instance:scoring=MeanAbsoluteError(). For multi-metric search, pass a dict:scoring={"mae": MeanAbsoluteError(), "mse": MeanSquaredError()}. - Problem: Results are not reproducible
- Wrap the sampler with
Samplerand passseed=. Usen_jobs=1because parallel trial ordering is non-deterministic. See Configure OptunaSearchCV. - Problem: All trials return NaN
- The forecaster may be failing silently. Set
error_score="raise"to surface the underlying error. See Handle Fitting Errors. - Problem: Search is slow
- Reduce
n_trialsor set atimeoutto cap execution time. Check thatn_splitsin your splitter is not too large. Consider usingn_jobs=-1for parallel trial execution on a single machine, or distribute trials across multiple nodes with a shared database storage (see Concepts: Parallelism). - Problem: CMA-ES sampler raises an error
- CMA-ES does not support
CategoricalDistributionparameters. UseTPESamplerfor mixed search spaces.
Parameter Routing¶
- Problem:
ValueError: Invalid parameter ... for estimator - The nested parameter path is wrong. For a parameter
alphaon theestimatorinside aPointReductionForecaster, use"estimator__alpha"(two underscores). Verify the full path withforecaster.get_params(deep=True). - Problem:
AttributeErrorwhen cloning (__init__parameter not found) - This usually means a custom estimator or wrapper is missing a constructor parameter that
clone()expects. Ensure all__init__parameters are stored as attributes with the same name. - Problem: Fitting failures from invalid parameter values
- By default,
error_score=np.nancatches errors during cross-validation folds and recordsNaNfor that trial. However, the best-found parameters are still used for refitting on the full dataset after all trials complete. If all trials failed, the refit step will raise. Check that your distribution ranges only produce valid values (e.g.,FloatDistribution(1e-4, 10.0)instead of ranges that include negative or zero values for parameters likealpha).
Cross-Validation Issues¶
- Problem: Optimistic CV scores that do not hold out-of-sample
- Increase
n_splitsin your splitter, or switch toExpandingWindowSplitterif you are usingSlidingWindowSplitter. Ensure the forecast horizon incvmatches the horizon you will use at inference. - Problem:
ValueError: Not enough data for the requested number of splits - The training series is too short for the configured splitter. Reduce
n_splitsorforecasting_horizon, or use a shorter minimum training window.
Scoring Issues¶
- Problem:
ValueError: scoring must be an instance of BaseScorer or a dict - You passed
scoringas a list. Only a single scorer or a dict of scorers is supported. Replacescoring=[MeanAbsoluteError(), MeanSquaredError()]withscoring={"mae": MeanAbsoluteError(), "mse": MeanSquaredError()}. - Problem:
ValueError: For multi-metric scoring, the parameter refit must be set to a scorer key - When
scoringis a dict, setrefitto one of the dictionary keys. For example, withscoring={"mae": MeanAbsoluteError(), "mse": MeanSquaredError()}, userefit="mae". If you do not need refitting, setrefit=False.
Storage Issues¶
- Problem: Study not resuming from database
- Make sure you use the same
study_nameandStorageconfiguration. See Persist and Resume Studies. - Problem:
OperationalError: unable to open database file - The directory for the SQLite database does not exist. Create it first:
mkdir -p path/to/dir.