如何在 Auto-Sklearn 中指定 Search Space

How to specify Search Space in Auto-Sklearn

我知道如何指定特征选择方法和 Auto-Sklearn 2.0 中使用的算法列表

mdl = autosklearn.classification.AutoSklearnClassifier(
    include = {
         'classifier': ["random_forest", "gaussian_nb", "libsvm_svc", "adaboost"],
         'feature_preprocessor': ["no_preprocessing"]
    },
    exclude=None)

我知道 Auto-Sklearn 使用贝叶斯优化 SMAC

但我想在 AutoSklearn 中指定超参数

例如,我想指定 random_forest 仅 Estimator = 1000 或 MLP 仅 HiddenLayerSize = 100

怎么做?

您需要按照 docs 中指定的方式编辑配置。

在你的情况下它会是这样的:

cs = mdl.get_configuration_space(X, y)
config = cs.sample_configuration()
config._values['classifier:random_forest:n_estimators'] = 1000
pipeline, run_info, run_value = mdl.fit_pipeline(X=X_train, y=y_train,
                                                 config=config,
                                                 X_test=X_test, y_test=y_test)