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进行两个步骤。
- 添加导入语句:
from optuna_fast_fanova import FanovaImportanceEvaluator
。 - 将
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的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | fba6f5133225903facd94f12b09c729544062b804edf0d7b7f0d521762dfe45d |
|
MD5 | fcef9e268341324f1e440147d65c52f9 |
|
BLAKE2b-256 | 2f3e5b4bfa03413b12d6456da63d67173396c5a562b427fbc75a4ebb2efd1d31 |