Fork me on GitHub
auto-sklearn 0.15.0
  • 首页
  • 版本发布
  • 安装
  • 手册
  • 示例
  • API
  • 扩展
  • 常见问题
  • 站点
    • 随机搜索
      • 数据加载
      • 使用 ROAR 拟合分类器
      • 使用随机搜索拟合分类器

    注意

    点击此处下载完整示例代码或通过 Binder 在浏览器中运行此示例

    随机搜索¶

    auto-sklearn 的一个关键特性是自动通过 SMAC 优化超参数,SMAC 在此处介绍。此外,也可以使用随机搜索代替 SMAC,如下面的示例所示。此外,本示例还演示了如何使用随机在线激进竞速 (ROAR) 作为另一种替代优化策略。这两个示例旨在展示 auto-sklearn 中的优化策略如何进行调整。

    from pprint import pprint
    
    import sklearn.model_selection
    import sklearn.datasets
    import sklearn.metrics
    
    from smac.facade.roar_facade import ROAR
    from smac.scenario.scenario import Scenario
    
    import autosklearn.classification
    

    数据加载¶

    X, y = sklearn.datasets.load_breast_cancer(return_X_y=True)
    X_train, X_test, y_train, y_test = sklearn.model_selection.train_test_split(
        X, y, random_state=1
    )
    

    使用 ROAR 拟合分类器¶

    def get_roar_object_callback(
        scenario_dict,
        seed,
        ta,
        ta_kwargs,
        metalearning_configurations,
        n_jobs,
        dask_client,
        multi_objective_algorithm,  # This argument will be ignored as ROAR does not yet support multi-objective optimization
        multi_objective_kwargs,
    ):
        """Random online adaptive racing."""
    
        if n_jobs > 1 or (dask_client and len(dask_client.nthreads()) > 1):
            raise ValueError(
                "Please make sure to guard the code invoking Auto-sklearn by "
                "`if __name__ == '__main__'` and remove this exception."
            )
    
        scenario = Scenario(scenario_dict)
        return ROAR(
            scenario=scenario,
            rng=seed,
            tae_runner=ta,
            tae_runner_kwargs=ta_kwargs,
            run_id=seed,
            dask_client=dask_client,
            n_jobs=n_jobs,
        )
    
    
    automl = autosklearn.classification.AutoSklearnClassifier(
        time_left_for_this_task=60,
        per_run_time_limit=15,
        tmp_folder="/tmp/autosklearn_random_search_example_tmp",
        initial_configurations_via_metalearning=0,
        # The callback to get the SMAC object
        get_smac_object_callback=get_roar_object_callback,
    )
    automl.fit(X_train, y_train, dataset_name="breast_cancer")
    
    print("#" * 80)
    print("Results for ROAR.")
    # Print the final ensemble constructed by auto-sklearn via ROAR.
    pprint(automl.show_models(), indent=4)
    predictions = automl.predict(X_test)
    # Print statistics about the auto-sklearn run such as number of
    # iterations, number of models failed with a time out.
    print(automl.sprint_statistics())
    print("Accuracy score", sklearn.metrics.accuracy_score(y_test, predictions))
    
    ################################################################################
    Results for ROAR.
    {   2: {   'balancing': Balancing(random_state=1),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d3b2c4c0>,
               'cost': 0.028368794326241176,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d1e35a30>,
               'ensemble_weight': 0.06,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d3b2c280>,
               'model_id': 2,
               'rank': 1,
               'sklearn_classifier': RandomForestClassifier(max_features=5, n_estimators=512, n_jobs=1,
                           random_state=1, warm_start=True)},
        3: {   'balancing': Balancing(random_state=1),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1bb37c0>,
               'cost': 0.07092198581560283,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d4452910>,
               'ensemble_weight': 0.04,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d4495520>,
               'model_id': 3,
               'rank': 2,
               'sklearn_classifier': PassiveAggressiveClassifier(C=0.10318256510142626, average=True, max_iter=32,
                                random_state=1, tol=0.0013607858153657413,
                                warm_start=True)},
        4: {   'balancing': Balancing(random_state=1, strategy='weighting'),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1b2b9a0>,
               'cost': 0.08510638297872342,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d3b2c8e0>,
               'ensemble_weight': 0.02,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d154f970>,
               'model_id': 4,
               'rank': 3,
               'sklearn_classifier': PassiveAggressiveClassifier(C=0.000505280701827856, max_iter=32, random_state=1,
                                tol=0.06421873693006744, warm_start=True)},
        5: {   'balancing': Balancing(random_state=1, strategy='weighting'),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1417490>,
               'cost': 0.021276595744680882,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d1aa6e50>,
               'ensemble_weight': 0.04,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1417100>,
               'model_id': 5,
               'rank': 4,
               'sklearn_classifier': HistGradientBoostingClassifier(early_stopping=True,
                                   l2_regularization=1.4469619760002166e-09,
                                   learning_rate=0.12309321429220763, max_iter=256,
                                   max_leaf_nodes=10, min_samples_leaf=17,
                                   n_iter_no_change=16, random_state=1,
                                   validation_fraction=None, warm_start=True)},
        7: {   'balancing': Balancing(random_state=1),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d458d8e0>,
               'cost': 0.36879432624113473,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d2413730>,
               'ensemble_weight': 0.04,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d4547af0>,
               'model_id': 7,
               'rank': 5,
               'sklearn_classifier': BernoulliNB(alpha=0.020898102999400082)},
        8: {   'balancing': Balancing(random_state=1, strategy='weighting'),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1a524c0>,
               'cost': 0.028368794326241176,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d4133610>,
               'ensemble_weight': 0.1,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1a52c70>,
               'model_id': 8,
               'rank': 6,
               'sklearn_classifier': PassiveAggressiveClassifier(C=5.4951544593926646e-05, average=True, max_iter=16,
                                random_state=1, tol=0.012344344043531127,
                                warm_start=True)},
        9: {   'balancing': Balancing(random_state=1, strategy='weighting'),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1c152b0>,
               'cost': 0.12056737588652477,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d6234430>,
               'ensemble_weight': 0.08,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1c15940>,
               'model_id': 9,
               'rank': 7,
               'sklearn_classifier': PassiveAggressiveClassifier(C=0.09581923415311244, max_iter=64, random_state=1,
                                tol=0.000145918046557035, warm_start=True)},
        10: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d411bfd0>,
                'cost': 0.16312056737588654,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d614df70>,
                'ensemble_weight': 0.04,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d411b700>,
                'model_id': 10,
                'rank': 8,
                'sklearn_classifier': ExtraTreesClassifier(criterion='entropy', max_features=2, min_samples_leaf=11,
                         min_samples_split=19, n_estimators=512, n_jobs=1,
                         random_state=1, warm_start=True)},
        11: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05ca2e0b50>,
                'cost': 0.028368794326241176,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d3d35e50>,
                'ensemble_weight': 0.06,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d681f490>,
                'model_id': 11,
                'rank': 9,
                'sklearn_classifier': LinearDiscriminantAnalysis(shrinkage='auto', solver='lsqr',
                               tol=0.039339489121391846)},
        12: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d2403640>,
                'cost': 0.13475177304964536,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d45bd820>,
                'ensemble_weight': 0.06,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05cb155400>,
                'model_id': 12,
                'rank': 10,
                'sklearn_classifier': LinearDiscriminantAnalysis(tol=0.0004182629077658861)},
        13: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d61cdac0>,
                'cost': 0.36879432624113473,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d25bfe20>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d3f33850>,
                'model_id': 13,
                'rank': 11,
                'sklearn_classifier': ExtraTreesClassifier(bootstrap=True, criterion='entropy', max_features=1,
                         min_samples_leaf=20, min_samples_split=20,
                         n_estimators=512, n_jobs=1, random_state=1,
                         warm_start=True)},
        14: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1ea3f70>,
                'cost': 0.028368794326241176,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05cb2442b0>,
                'ensemble_weight': 0.06,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1ea36a0>,
                'model_id': 14,
                'rank': 12,
                'sklearn_classifier': LinearDiscriminantAnalysis(shrinkage='auto', solver='lsqr',
                               tol=0.013943862590174107)},
        15: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d60168e0>,
                'cost': 0.16312056737588654,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d248cbe0>,
                'ensemble_weight': 0.04,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1a42040>,
                'model_id': 15,
                'rank': 13,
                'sklearn_classifier': DecisionTreeClassifier(class_weight='balanced', criterion='entropy',
                           max_depth=1, min_samples_leaf=3, min_samples_split=13,
                           random_state=1)},
        16: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1c00d90>,
                'cost': 0.06382978723404253,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05c6e48fd0>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1c00340>,
                'model_id': 16,
                'rank': 14,
                'sklearn_classifier': GaussianNB()},
        17: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05ce652e20>,
                'cost': 0.07801418439716312,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d43afc40>,
                'ensemble_weight': 0.06,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05ce652d00>,
                'model_id': 17,
                'rank': 15,
                'sklearn_classifier': PassiveAggressiveClassifier(C=0.04885675602027957, average=True, max_iter=64,
                                random_state=1, tol=0.0002678322187543955,
                                warm_start=True)},
        18: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d3e68a90>,
                'cost': 0.1063829787234043,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d21436d0>,
                'ensemble_weight': 0.1,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d3e68460>,
                'model_id': 18,
                'rank': 16,
                'sklearn_classifier': SGDClassifier(alpha=0.0002548862311968591, average=True,
                  eta0=4.278565071229579e-05, learning_rate='constant',
                  loss='squared_hinge', max_iter=1024, random_state=1,
                  tol=5.482673674397374e-05, warm_start=True)},
        19: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d684e610>,
                'cost': 0.09219858156028371,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d0f2ebe0>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d684eca0>,
                'model_id': 19,
                'rank': 17,
                'sklearn_classifier': AdaBoostClassifier(base_estimator=DecisionTreeClassifier(max_depth=7),
                       learning_rate=0.035867722843024794, n_estimators=70,
                       random_state=1)},
        23: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d19ad940>,
                'cost': 0.07801418439716312,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05cc69a1c0>,
                'ensemble_weight': 0.04,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d19ad2b0>,
                'model_id': 23,
                'rank': 18,
                'sklearn_classifier': MLPClassifier(activation='tanh', alpha=0.02522490081077779, beta_1=0.999,
                  beta_2=0.9, early_stopping=True, hidden_layer_sizes=(35,),
                  learning_rate_init=0.026536043936270744, max_iter=32,
                  n_iter_no_change=32, random_state=1, verbose=0, warm_start=True)},
        24: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1b78d90>,
                'cost': 0.028368794326241176,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d2001670>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1b787c0>,
                'model_id': 24,
                'rank': 19,
                'sklearn_classifier': LinearDiscriminantAnalysis(shrinkage='auto', solver='lsqr',
                               tol=0.001678686694320821)},
        25: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d62b9e50>,
                'cost': 0.021276595744680882,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d1efefd0>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d62b9400>,
                'model_id': 25,
                'rank': 20,
                'sklearn_classifier': HistGradientBoostingClassifier(early_stopping=True,
                                   l2_regularization=2.1928852428306468e-08,
                                   learning_rate=0.29557366541255203, max_iter=64,
                                   max_leaf_nodes=70, min_samples_leaf=24,
                                   random_state=1,
                                   validation_fraction=0.13252036572629863,
                                   warm_start=True)},
        26: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d61d3700>,
                'cost': 0.08510638297872342,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d1df5100>,
                'ensemble_weight': 0.06,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d154f040>,
                'model_id': 26,
                'rank': 21,
                'sklearn_classifier': KNeighborsClassifier(n_neighbors=80, p=1)}}
    auto-sklearn results:
      Dataset name: breast_cancer
      Metric: accuracy
      Best validation score: 0.978723
      Number of target algorithm runs: 26
      Number of successful target algorithm runs: 25
      Number of crashed target algorithm runs: 0
      Number of target algorithms that exceeded the time limit: 1
      Number of target algorithms that exceeded the memory limit: 0
    
    Accuracy score 0.965034965034965
    

    使用随机搜索拟合分类器¶

    def get_random_search_object_callback(
        scenario_dict,
        seed,
        ta,
        ta_kwargs,
        metalearning_configurations,
        n_jobs,
        dask_client,
        multi_objective_algorithm,  # This argument will be ignored as ROAR does not yet support multi-objective optimization
        multi_objective_kwargs,
    ):
        """Random search"""
    
        if n_jobs > 1 or (dask_client and len(dask_client.nthreads()) > 1):
            raise ValueError(
                "Please make sure to guard the code invoking Auto-sklearn by "
                "`if __name__ == '__main__'` and remove this exception."
            )
    
        scenario_dict["minR"] = len(scenario_dict["instances"])
        scenario_dict["initial_incumbent"] = "RANDOM"
        scenario = Scenario(scenario_dict)
        return ROAR(
            scenario=scenario,
            rng=seed,
            tae_runner=ta,
            tae_runner_kwargs=ta_kwargs,
            run_id=seed,
            dask_client=dask_client,
            n_jobs=n_jobs,
        )
    
    
    automl = autosklearn.classification.AutoSklearnClassifier(
        time_left_for_this_task=60,
        per_run_time_limit=15,
        tmp_folder="/tmp/autosklearn_random_search_example_tmp",
        initial_configurations_via_metalearning=0,
        # Passing the callback to get the SMAC object
        get_smac_object_callback=get_random_search_object_callback,
    )
    automl.fit(X_train, y_train, dataset_name="breast_cancer")
    
    print("#" * 80)
    print("Results for random search.")
    
    # Print the final ensemble constructed by auto-sklearn via random search.
    pprint(automl.show_models(), indent=4)
    
    # Print statistics about the auto-sklearn run such as number of
    # iterations, number of models failed with a time out.
    print(automl.sprint_statistics())
    
    predictions = automl.predict(X_test)
    print("Accuracy score", sklearn.metrics.accuracy_score(y_test, predictions))
    
    ################################################################################
    Results for random search.
    {   3: {   'balancing': Balancing(random_state=1, strategy='weighting'),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d618d640>,
               'cost': 0.08510638297872342,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d618d820>,
               'ensemble_weight': 0.04,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d618df40>,
               'model_id': 3,
               'rank': 1,
               'sklearn_classifier': PassiveAggressiveClassifier(C=0.000505280701827856, max_iter=32, random_state=1,
                                tol=0.06421873693006744, warm_start=True)},
        4: {   'balancing': Balancing(random_state=1, strategy='weighting'),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1df5070>,
               'cost': 0.021276595744680882,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d16ce850>,
               'ensemble_weight': 0.06,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1df5ca0>,
               'model_id': 4,
               'rank': 2,
               'sklearn_classifier': HistGradientBoostingClassifier(early_stopping=True,
                                   l2_regularization=1.4469619760002166e-09,
                                   learning_rate=0.12309321429220763, max_iter=256,
                                   max_leaf_nodes=10, min_samples_leaf=17,
                                   n_iter_no_change=16, random_state=1,
                                   validation_fraction=None, warm_start=True)},
        5: {   'balancing': Balancing(random_state=1),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d684ea90>,
               'cost': 0.028368794326241176,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05cc052df0>,
               'ensemble_weight': 0.14,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d684e070>,
               'model_id': 5,
               'rank': 3,
               'sklearn_classifier': RandomForestClassifier(max_features=5, n_estimators=512, n_jobs=1,
                           random_state=1, warm_start=True)},
        6: {   'balancing': Balancing(random_state=1),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d3e68190>,
               'cost': 0.028368794326241176,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d611da60>,
               'ensemble_weight': 0.06,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1d96220>,
               'model_id': 6,
               'rank': 4,
               'sklearn_classifier': LinearDiscriminantAnalysis(tol=0.08622878828999171)},
        7: {   'balancing': Balancing(random_state=1),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d4024820>,
               'cost': 0.36879432624113473,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d4573b20>,
               'ensemble_weight': 0.04,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d6403370>,
               'model_id': 7,
               'rank': 5,
               'sklearn_classifier': BernoulliNB(alpha=0.020898102999400082)},
        9: {   'balancing': Balancing(random_state=1, strategy='weighting'),
               'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d103b790>,
               'cost': 0.12056737588652477,
               'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d448d3d0>,
               'ensemble_weight': 0.06,
               'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d103bd30>,
               'model_id': 9,
               'rank': 6,
               'sklearn_classifier': PassiveAggressiveClassifier(C=0.09581923415311244, max_iter=64, random_state=1,
                                tol=0.000145918046557035, warm_start=True)},
        10: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1ad43d0>,
                'cost': 0.16312056737588654,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05cb27baf0>,
                'ensemble_weight': 0.06,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1ad4310>,
                'model_id': 10,
                'rank': 7,
                'sklearn_classifier': ExtraTreesClassifier(criterion='entropy', max_features=2, min_samples_leaf=11,
                         min_samples_split=19, n_estimators=512, n_jobs=1,
                         random_state=1, warm_start=True)},
        11: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d61e5be0>,
                'cost': 0.028368794326241176,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d221fe50>,
                'ensemble_weight': 0.06,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d457f9a0>,
                'model_id': 11,
                'rank': 8,
                'sklearn_classifier': LinearDiscriminantAnalysis(shrinkage='auto', solver='lsqr',
                               tol=0.039339489121391846)},
        12: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d25bf490>,
                'cost': 0.13475177304964536,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d1ea3460>,
                'ensemble_weight': 0.08,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1e27820>,
                'model_id': 12,
                'rank': 9,
                'sklearn_classifier': LinearDiscriminantAnalysis(tol=0.0004182629077658861)},
        13: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d0caa700>,
                'cost': 0.36879432624113473,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d62fd250>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d0caae20>,
                'model_id': 13,
                'rank': 10,
                'sklearn_classifier': ExtraTreesClassifier(bootstrap=True, criterion='entropy', max_features=1,
                         min_samples_leaf=20, min_samples_split=20,
                         n_estimators=512, n_jobs=1, random_state=1,
                         warm_start=True)},
        14: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d0f45820>,
                'cost': 0.028368794326241176,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05cc0528b0>,
                'ensemble_weight': 0.04,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d45474c0>,
                'model_id': 14,
                'rank': 11,
                'sklearn_classifier': LinearDiscriminantAnalysis(shrinkage='auto', solver='lsqr',
                               tol=0.013943862590174107)},
        15: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05cc79a910>,
                'cost': 0.16312056737588654,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d1ef6310>,
                'ensemble_weight': 0.04,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d3d93940>,
                'model_id': 15,
                'rank': 12,
                'sklearn_classifier': DecisionTreeClassifier(class_weight='balanced', criterion='entropy',
                           max_depth=1, min_samples_leaf=3, min_samples_split=13,
                           random_state=1)},
        16: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1c0eeb0>,
                'cost': 0.06382978723404253,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d2165070>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1c0e7c0>,
                'model_id': 16,
                'rank': 13,
                'sklearn_classifier': GaussianNB()},
        17: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1e355b0>,
                'cost': 0.07801418439716312,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d0fc0790>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1e35850>,
                'model_id': 17,
                'rank': 14,
                'sklearn_classifier': PassiveAggressiveClassifier(C=0.04885675602027957, average=True, max_iter=64,
                                random_state=1, tol=0.0002678322187543955,
                                warm_start=True)},
        18: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d3dcb370>,
                'cost': 0.1063829787234043,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05ca268730>,
                'ensemble_weight': 0.06,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d3dcb190>,
                'model_id': 18,
                'rank': 15,
                'sklearn_classifier': SGDClassifier(alpha=0.0002548862311968591, average=True,
                  eta0=4.278565071229579e-05, learning_rate='constant',
                  loss='squared_hinge', max_iter=1024, random_state=1,
                  tol=5.482673674397374e-05, warm_start=True)},
        19: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05ca2e0700>,
                'cost': 0.09219858156028371,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d0ccb430>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05ca2e0340>,
                'model_id': 19,
                'rank': 16,
                'sklearn_classifier': AdaBoostClassifier(base_estimator=DecisionTreeClassifier(max_depth=7),
                       learning_rate=0.035867722843024794, n_estimators=70,
                       random_state=1)},
        20: {   'balancing': Balancing(random_state=1),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d3b2c4f0>,
                'cost': 0.07092198581560283,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d0fd70a0>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d3b2c970>,
                'model_id': 20,
                'rank': 17,
                'sklearn_classifier': AdaBoostClassifier(algorithm='SAMME',
                       base_estimator=DecisionTreeClassifier(max_depth=9),
                       learning_rate=0.21684295401135145, n_estimators=72,
                       random_state=1)},
        23: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1c62880>,
                'cost': 0.07801418439716312,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d2413fd0>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1c62580>,
                'model_id': 23,
                'rank': 18,
                'sklearn_classifier': MLPClassifier(activation='tanh', alpha=0.02522490081077779, beta_1=0.999,
                  beta_2=0.9, early_stopping=True, hidden_layer_sizes=(35,),
                  learning_rate_init=0.026536043936270744, max_iter=32,
                  n_iter_no_change=32, random_state=1, verbose=0, warm_start=True)},
        24: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d624be50>,
                'cost': 0.028368794326241176,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d3aee2e0>,
                'ensemble_weight': 0.06,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d624bd90>,
                'model_id': 24,
                'rank': 19,
                'sklearn_classifier': LinearDiscriminantAnalysis(shrinkage='auto', solver='lsqr',
                               tol=0.001678686694320821)},
        25: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d1bf6280>,
                'cost': 0.021276595744680882,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d0c32c40>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d1bf6d00>,
                'model_id': 25,
                'rank': 20,
                'sklearn_classifier': HistGradientBoostingClassifier(early_stopping=True,
                                   l2_regularization=2.1928852428306468e-08,
                                   learning_rate=0.29557366541255203, max_iter=64,
                                   max_leaf_nodes=70, min_samples_leaf=24,
                                   random_state=1,
                                   validation_fraction=0.13252036572629863,
                                   warm_start=True)},
        26: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d62efb20>,
                'cost': 0.08510638297872342,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d1c62ca0>,
                'ensemble_weight': 0.02,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d3b0e820>,
                'model_id': 26,
                'rank': 21,
                'sklearn_classifier': KNeighborsClassifier(n_neighbors=80, p=1)},
        27: {   'balancing': Balancing(random_state=1, strategy='weighting'),
                'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7f05d438e1f0>,
                'cost': 0.375886524822695,
                'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7f05d1b2bbe0>,
                'ensemble_weight': 0.04,
                'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7f05d482d310>,
                'model_id': 27,
                'rank': 22,
                'sklearn_classifier': BernoulliNB(alpha=9.144520523203797)}}
    auto-sklearn results:
      Dataset name: breast_cancer
      Metric: accuracy
      Best validation score: 0.978723
      Number of target algorithm runs: 26
      Number of successful target algorithm runs: 26
      Number of crashed target algorithm runs: 0
      Number of target algorithms that exceeded the time limit: 0
      Number of target algorithms that exceeded the memory limit: 0
    
    Accuracy score 0.972027972027972
    

    脚本总运行时间: ( 1 分 56.774 秒)

    Launch binder

    下载 Python 源代码: example_random_search.py

    下载 Jupyter notebook: example_random_search.ipynb

    由 Sphinx-Gallery 生成的图库

    返回顶部

    源代码

    © 版权所有 2014-2022, 弗莱堡机器学习教授席。
    使用 Sphinx 4.2.0 创建。