Skip to main content

An Optuna integration for hyperparameter tuning in Yohou

Project description

Yohou-Optuna

Python Version License PyPI Version Conda Version codecov

What is Yohou-Optuna?

Yohou-Optuna brings Optuna's hyperparameter optimization to Yohou, providing a Yohou-compatible search class for time series forecasting.

This integration replaces grid and random search with adaptive sampling (TPE, CMA-ES, and more) while keeping Yohou's forecasting API intact. After fitting, OptunaSearchCV behaves like a Yohou forecaster, so you can call predict, observe, and observe_predict directly.

It integrates with Optuna's distributions, samplers, and storages, and wraps them for sklearn-style cloning and serialization.

What are the features of Yohou-Optuna?

  • Adaptive optimization: Run Optuna studies over Yohou forecasters with TPE, CMA-ES, and other samplers to find better configurations in fewer trials.
  • Forecaster-native API: OptunaSearchCV is a forecaster after fitting, so you can call predict, observe, observe_predict, and interval methods.
  • Clone-safe wrappers: Sampler, Storage, and Callback wrappers ensure Optuna objects survive sklearn cloning and serialization.
  • Time-series CV support: Works with Yohou splitters for proper temporal validation and scorer integration.
  • Multi-metric evaluation: Evaluate multiple scorers and refit on the one that matters most for your use case.
  • (Experimental) Persistence workflows: Resume studies with storage-backed optimization and continue tuning over time.

How to install Yohou-Optuna?

Install the Yohou-Optuna package using pip:

pip install yohou_optuna

or using uv:

uv pip install yohou_optuna

or using conda:

conda install -c conda-forge yohou_optuna

or using mamba:

mamba install -c conda-forge yohou_optuna

or alternatively, add yohou_optuna to your requirements.txt or pyproject.toml file.

How to get started with Yohou-Optuna?

1. Prepare a forecaster and search space

Define a Yohou forecaster and Optuna distributions for the parameters you want to tune.

from sklearn.linear_model import Ridge
from optuna.distributions import FloatDistribution, IntDistribution

from yohou.point import PointReductionForecaster
from yohou_optuna import OptunaSearchCV

forecaster = PointReductionForecaster(estimator=Ridge())
param_distributions = {
    "estimator__alpha": FloatDistribution(1e-4, 10.0, log=True),
    "observation_horizon": IntDistribution(3, 30),
}

search = OptunaSearchCV(
    forecaster=forecaster,
    param_distributions=param_distributions,
    n_trials=30,
)

2. Fit the searcher

Fit the searcher on your time series data (polars DataFrame with a time column).

search.fit(y_train, X_train, forecasting_horizon=12)

3. Predict with the best forecaster

After fitting, search behaves like a Yohou forecaster.

y_pred = search.predict(forecasting_horizon=12)
print(search.best_params_)

How do I use Yohou-Optuna?

Full documentation is available at https://yohou-optuna.readthedocs.io/.

Interactive examples are available in the examples/ directory:

Can I contribute?

We welcome contributions, feedback, and questions:

If you are interested in becoming a maintainer or taking a more active role, please reach out to Guillaume Tauzin on GitHub Discussions.

Where can I learn more?

Here are the main Yohou-Optuna resources:

For questions and discussions, you can also open a discussion.

License

This project is licensed under the terms of the Apache-2.0 License.

Acknowledgements

This project is maintained by stateful-y, an ML consultancy specializing in time series data science & engineering. If you're interested in collaborating or learning more about our services, please visit our website.

Made by stateful-y

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yohou_optuna-0.1.0a4.tar.gz (171.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yohou_optuna-0.1.0a4-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file yohou_optuna-0.1.0a4.tar.gz.

File metadata

  • Download URL: yohou_optuna-0.1.0a4.tar.gz
  • Upload date:
  • Size: 171.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yohou_optuna-0.1.0a4.tar.gz
Algorithm Hash digest
SHA256 8584c09a9a74292df559e9c03d043af58013e4f96fda740ea25e682ac4bd0aab
MD5 5fd32a5da490e8d4bbc2cd8192a55a97
BLAKE2b-256 434db1f7687e8e10093273d5ca31d6a7ab286e1b8b9254d871644897fa9a2136

See more details on using hashes here.

Provenance

The following attestation bundles were made for yohou_optuna-0.1.0a4.tar.gz:

Publisher: publish-release.yml on stateful-y/yohou-optuna

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yohou_optuna-0.1.0a4-py3-none-any.whl.

File metadata

  • Download URL: yohou_optuna-0.1.0a4-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yohou_optuna-0.1.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 b8946c17c161f9fa5342da2b576dcff50aade5a1b3b042898f6e0d914bfd8705
MD5 5784b0cc96030a567c54ec8d11bb29a9
BLAKE2b-256 41194b88c3ff3e4024f888282bd2125e6c8ef178c5d8c7c6e4684d87b1e60316

See more details on using hashes here.

Provenance

The following attestation bundles were made for yohou_optuna-0.1.0a4-py3-none-any.whl:

Publisher: publish-release.yml on stateful-y/yohou-optuna

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page