Skip to main content

Cython accelerated fANOVA implementation for Optuna

Project description

optuna-fast-fanova

optuna-fast-fanova provides Cython-accelerated version of FanovaImportanceEvaluator.

n_trials n_params n_trees fANOVA (Optuna) fast-fanova
1000 32 64 71.431s 2.963s (-95.9%)
1000 8 64 92.307s 2.315s (-97.5%)
1000 2 64 52.295s 1.297s (-97.5%)
100 32 64 1.668s 0.306s (-81.6%)
100 8 64 1.652s 0.138s (-91.7%)
100 2 64 1.242s 0.095s (-92.4%)

The benchmark script was run on my laptop (Macbook M1 Pro) so the times should not be taken precisely.

Installation

Supported Python versions are 3.7 or later.

$ pip install optuna-fast-fanova

Please note that this library depends on the scikit-learn's C-API (Cython pxd files). However, its ABI may contain breaking changes, even in patch releases. If you install optuna-fast-fanova with scikit-learn v1.1.1 and then upgrade scikit-learn to v1.1.2, optuna-fast-fanova will not work. Please reinstall optuna-fast-fanova if you update scikit-learn.

Usage

Usage is like this:

import optuna
from optuna_fast_fanova import FanovaImportanceEvaluator


def objective(trial):
    x = trial.suggest_float("x", -10, 10)
    y = trial.suggest_int("y", -10, 10)
    return x ** 2 + y


if __name__ == "__main__":
    study = optuna.create_study()
    study.optimize(objective, n_trials=1000)

    importance = optuna.importance.get_param_importances(
        study, evaluator=FanovaImportanceEvaluator()
    )
    print(importance)

You can use optuna-fast-fanova in only two steps.

  1. Add an import statement: from optuna_fast_fanova import FanovaImportanceEvaluator.
  2. Pass a FanovaImportanceEvaluator() object to an evaluator argument of get_param_importances() function.

How to cite fANOVA

This is a derived work of https://github.com/automl/fanova. For how to cite the original work, please refer to https://automl.github.io/fanova/cite.html.

Download files

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

Source Distribution

optuna-fast-fanova-0.0.4.tar.gz (30.8 kB view details)

Uploaded Source

File details

Details for the file optuna-fast-fanova-0.0.4.tar.gz.

File metadata

  • Download URL: optuna-fast-fanova-0.0.4.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.11

File hashes

Hashes for optuna-fast-fanova-0.0.4.tar.gz
Algorithm Hash digest
SHA256 fba6f5133225903facd94f12b09c729544062b804edf0d7b7f0d521762dfe45d
MD5 fcef9e268341324f1e440147d65c52f9
BLAKE2b-256 2f3e5b4bfa03413b12d6456da63d67173396c5a562b427fbc75a4ebb2efd1d31

See more details on using hashes here.

Supported by

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