跳转到主要内容

Optuna的Cython加速fANOVA实现

项目描述

optuna-fast-fanova

optuna-fast-fanova提供了FanovaImportanceEvaluator的Cython加速版本。

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%)

基准脚本在我的笔记本电脑(Macbook M1 Pro)上运行,因此时间不应被视为精确。

安装

支持的Python版本为3.7或更高。

$ pip install optuna-fast-fanova

请注意,此库依赖于scikit-learn的C-API(Cython pxd文件)。然而,其ABI可能包含破坏性更改,即使在修补版本中也是如此。如果您使用scikit-learn v1.1.1安装optuna-fast-fanova,然后升级scikit-learn到v1.1.2,optuna-fast-fanova将无法正常工作。如果您更新scikit-learn,请重新安装optuna-fast-fanova。

用法

用法如下

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)

您可以使用optuna-fast-fanova进行两个步骤。

  1. 添加导入语句: from optuna_fast_fanova import FanovaImportanceEvaluator
  2. FanovaImportanceEvaluator()对象传递给get_param_importances()函数的evaluator参数。

如何引用fANOVA

这是https://github.com/automl/fanova的衍生作品。有关如何引用原始作品的信息,请参阅https://automl.github.io/fanova/cite.html

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关安装软件包的更多信息。

源代码分布

optuna-fast-fanova-0.0.4.tar.gz (30.8 kB 查看哈希)

上传时间 源代码

支持者