.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/80_extending/example_restrict_number_of_hyperparameters.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_80_extending_example_restrict_number_of_hyperparameters.py: =================================================================== Restricting the number of hyperparameters for an existing component =================================================================== The following example demonstrates how to replace an existing component with a new component, implementing the same classifier, but with different hyperparameters . .. GENERATED FROM PYTHON SOURCE LINES 10-30 .. code-block:: default from typing import Optional from ConfigSpace.configuration_space import ConfigurationSpace from ConfigSpace.hyperparameters import ( UniformIntegerHyperparameter, UniformFloatHyperparameter, ) from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from autosklearn.askl_typing import FEAT_TYPE_TYPE import autosklearn.classification import autosklearn.pipeline.components.classification from autosklearn.pipeline.components.classification import ( AutoSklearnClassificationAlgorithm, ) from autosklearn.pipeline.constants import DENSE, UNSIGNED_DATA, PREDICTIONS, SPARSE .. GENERATED FROM PYTHON SOURCE LINES 31-33 Subclass auto-sklearn's random forest classifier ================================================ .. GENERATED FROM PYTHON SOURCE LINES 33-114 .. code-block:: default # This classifier only has one of the hyperparameter's of auto-sklearn's # default parametrization (``max_features``). Instead, it also # tunes the number of estimators (``n_estimators``). class CustomRandomForest(AutoSklearnClassificationAlgorithm): def __init__(self, n_estimators, max_features, random_state=None): self.n_estimators = n_estimators self.max_features = max_features self.random_state = random_state def fit(self, X, y): from sklearn.ensemble import RandomForestClassifier self.n_estimators = int(self.n_estimators) if self.max_features not in ("sqrt", "log2", "auto"): max_features = int(X.shape[1] ** float(self.max_features)) else: max_features = self.max_features self.estimator = RandomForestClassifier( n_estimators=self.n_estimators, max_features=max_features, random_state=self.random_state, ) self.estimator.fit(X, y) return self def predict(self, X): if self.estimator is None: raise NotImplementedError() return self.estimator.predict(X) def predict_proba(self, X): if self.estimator is None: raise NotImplementedError() return self.estimator.predict_proba(X) @staticmethod def get_properties(dataset_properties=None): return { "shortname": "RF", "name": "Random Forest Classifier", "handles_regression": False, "handles_classification": True, "handles_multiclass": True, "handles_multilabel": True, "handles_multioutput": False, "is_deterministic": True, "input": (DENSE, SPARSE, UNSIGNED_DATA), "output": (PREDICTIONS,), } @staticmethod def get_hyperparameter_search_space( feat_type: Optional[FEAT_TYPE_TYPE] = None, dataset_properties=None ): cs = ConfigurationSpace() # The maximum number of features used in the forest is calculated as m^max_features, where # m is the total number of features, and max_features is the hyperparameter specified below. # The default is 0.5, which yields sqrt(m) features as max_features in the estimator. This # corresponds with Geurts' heuristic. max_features = UniformFloatHyperparameter( "max_features", 0.0, 1.0, default_value=0.5 ) n_estimators = UniformIntegerHyperparameter( "n_estimators", 10, 1000, default_value=100 ) cs.add_hyperparameters([max_features, n_estimators]) return cs # Add custom random forest classifier component to auto-sklearn. autosklearn.pipeline.components.classification.add_classifier(CustomRandomForest) cs = CustomRandomForest.get_hyperparameter_search_space() print(cs) .. rst-class:: sphx-glr-script-out .. code-block:: none Configuration space object: Hyperparameters: max_features, Type: UniformFloat, Range: [0.0, 1.0], Default: 0.5 n_estimators, Type: UniformInteger, Range: [10, 1000], Default: 100 .. GENERATED FROM PYTHON SOURCE LINES 115-117 Data Loading ============ .. GENERATED FROM PYTHON SOURCE LINES 117-121 .. code-block:: default X, y = load_breast_cancer(return_X_y=True) X_train, X_test, y_train, y_test = train_test_split(X, y) .. GENERATED FROM PYTHON SOURCE LINES 122-124 Fit Random forest classifier to the data ======================================== .. GENERATED FROM PYTHON SOURCE LINES 124-137 .. code-block:: default clf = autosklearn.classification.AutoSklearnClassifier( time_left_for_this_task=30, per_run_time_limit=10, # Here we exclude auto-sklearn's default random forest component exclude={"classifier": ["random_forest"]}, # Bellow two flags are provided to speed up calculations # Not recommended for a real implementation initial_configurations_via_metalearning=0, smac_scenario_args={"runcount_limit": 1}, ) clf.fit(X_train, y_train) .. rst-class:: sphx-glr-script-out .. code-block:: none AutoSklearnClassifier(ensemble_class=, exclude={'classifier': ['random_forest']}, initial_configurations_via_metalearning=0, per_run_time_limit=10, smac_scenario_args={'runcount_limit': 1}, time_left_for_this_task=30) .. GENERATED FROM PYTHON SOURCE LINES 138-140 Print the configuration space ============================= .. GENERATED FROM PYTHON SOURCE LINES 140-146 .. code-block:: default # Observe that this configuration space only contains our custom random # forest, but not auto-sklearn's ``random_forest`` cs = clf.get_configuration_space(X_train, y_train) assert "random_forest" not in str(cs) print(cs) .. rst-class:: sphx-glr-script-out .. code-block:: none Configuration space object: Hyperparameters: balancing:strategy, Type: Categorical, Choices: {none, weighting}, Default: none classifier:CustomRandomForest:max_features, Type: UniformFloat, Range: [0.0, 1.0], Default: 0.5 classifier:CustomRandomForest:n_estimators, Type: UniformInteger, Range: [10, 1000], Default: 100 classifier:__choice__, Type: Categorical, Choices: {adaboost, bernoulli_nb, decision_tree, extra_trees, gaussian_nb, gradient_boosting, k_nearest_neighbors, lda, liblinear_svc, libsvm_svc, mlp, multinomial_nb, passive_aggressive, qda, sgd, CustomRandomForest}, Default: liblinear_svc classifier:adaboost:algorithm, Type: Categorical, Choices: {SAMME.R, SAMME}, Default: SAMME.R classifier:adaboost:learning_rate, Type: UniformFloat, Range: [0.01, 2.0], Default: 0.1, on log-scale classifier:adaboost:max_depth, Type: UniformInteger, Range: [1, 10], Default: 1 classifier:adaboost:n_estimators, Type: UniformInteger, Range: [50, 500], Default: 50 classifier:bernoulli_nb:alpha, Type: UniformFloat, Range: [0.01, 100.0], Default: 1.0, on log-scale classifier:bernoulli_nb:fit_prior, Type: Categorical, Choices: {True, False}, Default: True classifier:decision_tree:criterion, Type: Categorical, Choices: {gini, entropy}, Default: gini classifier:decision_tree:max_depth_factor, Type: UniformFloat, Range: [0.0, 2.0], Default: 0.5 classifier:decision_tree:max_features, Type: Constant, Value: 1.0 classifier:decision_tree:max_leaf_nodes, Type: Constant, Value: None classifier:decision_tree:min_impurity_decrease, Type: Constant, Value: 0.0 classifier:decision_tree:min_samples_leaf, Type: UniformInteger, Range: [1, 20], Default: 1 classifier:decision_tree:min_samples_split, Type: UniformInteger, Range: [2, 20], Default: 2 classifier:decision_tree:min_weight_fraction_leaf, Type: Constant, Value: 0.0 classifier:extra_trees:bootstrap, Type: Categorical, Choices: {True, False}, Default: False classifier:extra_trees:criterion, Type: Categorical, Choices: {gini, entropy}, Default: gini classifier:extra_trees:max_depth, Type: Constant, Value: None classifier:extra_trees:max_features, Type: UniformFloat, Range: [0.0, 1.0], Default: 0.5 classifier:extra_trees:max_leaf_nodes, Type: Constant, Value: None classifier:extra_trees:min_impurity_decrease, Type: Constant, Value: 0.0 classifier:extra_trees:min_samples_leaf, Type: UniformInteger, Range: [1, 20], Default: 1 classifier:extra_trees:min_samples_split, Type: UniformInteger, Range: [2, 20], Default: 2 classifier:extra_trees:min_weight_fraction_leaf, Type: Constant, Value: 0.0 classifier:gradient_boosting:early_stop, Type: Categorical, Choices: {off, valid, train}, Default: off classifier:gradient_boosting:l2_regularization, Type: UniformFloat, Range: [1e-10, 1.0], Default: 1e-10, on log-scale classifier:gradient_boosting:learning_rate, Type: UniformFloat, Range: [0.01, 1.0], Default: 0.1, on log-scale classifier:gradient_boosting:loss, Type: Constant, Value: auto classifier:gradient_boosting:max_bins, Type: Constant, Value: 255 classifier:gradient_boosting:max_depth, Type: Constant, Value: None classifier:gradient_boosting:max_leaf_nodes, Type: UniformInteger, Range: [3, 2047], Default: 31, on log-scale classifier:gradient_boosting:min_samples_leaf, Type: UniformInteger, Range: [1, 200], Default: 20, on log-scale classifier:gradient_boosting:n_iter_no_change, Type: UniformInteger, Range: [1, 20], Default: 10 classifier:gradient_boosting:scoring, Type: Constant, Value: loss classifier:gradient_boosting:tol, Type: Constant, Value: 1e-07 classifier:gradient_boosting:validation_fraction, Type: UniformFloat, Range: [0.01, 0.4], Default: 0.1 classifier:k_nearest_neighbors:n_neighbors, Type: UniformInteger, Range: [1, 100], Default: 1, on log-scale classifier:k_nearest_neighbors:p, Type: Categorical, Choices: {1, 2}, Default: 2 classifier:k_nearest_neighbors:weights, Type: Categorical, Choices: {uniform, distance}, Default: uniform classifier:lda:shrinkage, Type: Categorical, Choices: {None, auto, manual}, Default: None classifier:lda:shrinkage_factor, Type: UniformFloat, Range: [0.0, 1.0], Default: 0.5 classifier:lda:tol, Type: UniformFloat, Range: [1e-05, 0.1], Default: 0.0001, on log-scale classifier:liblinear_svc:C, Type: UniformFloat, Range: [0.03125, 32768.0], Default: 1.0, on log-scale classifier:liblinear_svc:dual, Type: Constant, Value: False classifier:liblinear_svc:fit_intercept, Type: Constant, Value: True classifier:liblinear_svc:intercept_scaling, Type: Constant, Value: 1 classifier:liblinear_svc:loss, Type: Categorical, Choices: {hinge, squared_hinge}, Default: squared_hinge classifier:liblinear_svc:multi_class, Type: Constant, Value: ovr classifier:liblinear_svc:penalty, Type: Categorical, Choices: {l1, l2}, Default: l2 classifier:liblinear_svc:tol, Type: UniformFloat, Range: [1e-05, 0.1], Default: 0.0001, on log-scale classifier:libsvm_svc:C, Type: UniformFloat, Range: [0.03125, 32768.0], Default: 1.0, on log-scale classifier:libsvm_svc:coef0, Type: UniformFloat, Range: [-1.0, 1.0], Default: 0.0 classifier:libsvm_svc:degree, Type: UniformInteger, Range: [2, 5], Default: 3 classifier:libsvm_svc:gamma, Type: UniformFloat, Range: [3.0517578125e-05, 8.0], Default: 0.1, on log-scale classifier:libsvm_svc:kernel, Type: Categorical, Choices: {rbf, poly, sigmoid}, Default: rbf classifier:libsvm_svc:max_iter, Type: Constant, Value: -1 classifier:libsvm_svc:shrinking, Type: Categorical, Choices: {True, False}, Default: True classifier:libsvm_svc:tol, Type: UniformFloat, Range: [1e-05, 0.1], Default: 0.001, on log-scale classifier:mlp:activation, Type: Categorical, Choices: {tanh, relu}, Default: relu classifier:mlp:alpha, Type: UniformFloat, Range: [1e-07, 0.1], Default: 0.0001, on log-scale classifier:mlp:batch_size, Type: Constant, Value: auto classifier:mlp:beta_1, Type: Constant, Value: 0.9 classifier:mlp:beta_2, Type: Constant, Value: 0.999 classifier:mlp:early_stopping, Type: Categorical, Choices: {valid, train}, Default: valid classifier:mlp:epsilon, Type: Constant, Value: 1e-08 classifier:mlp:hidden_layer_depth, Type: UniformInteger, Range: [1, 3], Default: 1 classifier:mlp:learning_rate_init, Type: UniformFloat, Range: [0.0001, 0.5], Default: 0.001, on log-scale classifier:mlp:n_iter_no_change, Type: Constant, Value: 32 classifier:mlp:num_nodes_per_layer, Type: UniformInteger, Range: [16, 264], Default: 32, on log-scale classifier:mlp:shuffle, Type: Constant, Value: True classifier:mlp:solver, Type: Constant, Value: adam classifier:mlp:tol, Type: Constant, Value: 0.0001 classifier:mlp:validation_fraction, Type: Constant, Value: 0.1 classifier:multinomial_nb:alpha, Type: UniformFloat, Range: [0.01, 100.0], Default: 1.0, on log-scale classifier:multinomial_nb:fit_prior, Type: Categorical, Choices: {True, False}, Default: True classifier:passive_aggressive:C, Type: UniformFloat, Range: [1e-05, 10.0], Default: 1.0, on log-scale classifier:passive_aggressive:average, Type: Categorical, Choices: {False, True}, Default: False classifier:passive_aggressive:fit_intercept, Type: Constant, Value: True classifier:passive_aggressive:loss, Type: Categorical, Choices: {hinge, squared_hinge}, Default: hinge classifier:passive_aggressive:tol, Type: UniformFloat, Range: [1e-05, 0.1], Default: 0.0001, on log-scale classifier:qda:reg_param, Type: UniformFloat, Range: [0.0, 1.0], Default: 0.0 classifier:sgd:alpha, Type: UniformFloat, Range: [1e-07, 0.1], Default: 0.0001, on log-scale classifier:sgd:average, Type: Categorical, Choices: {False, True}, Default: False classifier:sgd:epsilon, Type: UniformFloat, Range: [1e-05, 0.1], Default: 0.0001, on log-scale classifier:sgd:eta0, Type: UniformFloat, Range: [1e-07, 0.1], Default: 0.01, on log-scale classifier:sgd:fit_intercept, Type: Constant, Value: True classifier:sgd:l1_ratio, Type: UniformFloat, Range: [1e-09, 1.0], Default: 0.15, on log-scale classifier:sgd:learning_rate, Type: Categorical, Choices: {optimal, invscaling, constant}, Default: invscaling classifier:sgd:loss, Type: Categorical, Choices: {hinge, log, modified_huber, squared_hinge, perceptron}, Default: log classifier:sgd:penalty, Type: Categorical, Choices: {l1, l2, elasticnet}, Default: l2 classifier:sgd:power_t, Type: UniformFloat, Range: [1e-05, 1.0], Default: 0.5 classifier:sgd:tol, Type: UniformFloat, Range: [1e-05, 0.1], Default: 0.0001, on log-scale data_preprocessor:__choice__, Type: Categorical, Choices: {feature_type, NoPreprocessing}, Default: feature_type data_preprocessor:feature_type:numerical_transformer:imputation:strategy, Type: Categorical, Choices: {mean, median, most_frequent}, Default: mean data_preprocessor:feature_type:numerical_transformer:rescaling:__choice__, Type: Categorical, Choices: {minmax, none, normalize, power_transformer, quantile_transformer, robust_scaler, standardize}, Default: standardize data_preprocessor:feature_type:numerical_transformer:rescaling:quantile_transformer:n_quantiles, Type: UniformInteger, Range: [10, 2000], Default: 1000 data_preprocessor:feature_type:numerical_transformer:rescaling:quantile_transformer:output_distribution, Type: Categorical, Choices: {normal, uniform}, Default: normal data_preprocessor:feature_type:numerical_transformer:rescaling:robust_scaler:q_max, Type: UniformFloat, Range: [0.7, 0.999], Default: 0.75 data_preprocessor:feature_type:numerical_transformer:rescaling:robust_scaler:q_min, Type: UniformFloat, Range: [0.001, 0.3], Default: 0.25 feature_preprocessor:LDA:shrinkage, Type: UniformFloat, Range: [0.0, 1.0], Default: 0.5 feature_preprocessor:LDA:solver, Type: Categorical, Choices: {svd, lsqr, eigen}, Default: svd feature_preprocessor:LDA:tol, Type: UniformFloat, Range: [0.0001, 1.0], Default: 0.0001 feature_preprocessor:__choice__, Type: Categorical, Choices: {extra_trees_preproc_for_classification, fast_ica, feature_agglomeration, kernel_pca, kitchen_sinks, liblinear_svc_preprocessor, no_preprocessing, nystroem_sampler, pca, polynomial, random_trees_embedding, select_percentile_classification, select_rates_classification, LDA}, Default: no_preprocessing feature_preprocessor:extra_trees_preproc_for_classification:bootstrap, Type: Categorical, Choices: {True, False}, Default: False feature_preprocessor:extra_trees_preproc_for_classification:criterion, Type: Categorical, Choices: {gini, entropy}, Default: gini feature_preprocessor:extra_trees_preproc_for_classification:max_depth, Type: Constant, Value: None feature_preprocessor:extra_trees_preproc_for_classification:max_features, Type: UniformFloat, Range: [0.0, 1.0], Default: 0.5 feature_preprocessor:extra_trees_preproc_for_classification:max_leaf_nodes, Type: Constant, Value: None feature_preprocessor:extra_trees_preproc_for_classification:min_impurity_decrease, Type: Constant, Value: 0.0 feature_preprocessor:extra_trees_preproc_for_classification:min_samples_leaf, Type: UniformInteger, Range: [1, 20], Default: 1 feature_preprocessor:extra_trees_preproc_for_classification:min_samples_split, Type: UniformInteger, Range: [2, 20], Default: 2 feature_preprocessor:extra_trees_preproc_for_classification:min_weight_fraction_leaf, Type: Constant, Value: 0.0 feature_preprocessor:extra_trees_preproc_for_classification:n_estimators, Type: Constant, Value: 100 feature_preprocessor:fast_ica:algorithm, Type: Categorical, Choices: {parallel, deflation}, Default: parallel feature_preprocessor:fast_ica:fun, Type: Categorical, Choices: {logcosh, exp, cube}, Default: logcosh feature_preprocessor:fast_ica:n_components, Type: UniformInteger, Range: [10, 2000], Default: 100 feature_preprocessor:fast_ica:whiten, Type: Categorical, Choices: {False, True}, Default: False feature_preprocessor:feature_agglomeration:affinity, Type: Categorical, Choices: {euclidean, manhattan, cosine}, Default: euclidean feature_preprocessor:feature_agglomeration:linkage, Type: Categorical, Choices: {ward, complete, average}, Default: ward feature_preprocessor:feature_agglomeration:n_clusters, Type: UniformInteger, Range: [2, 400], Default: 25 feature_preprocessor:feature_agglomeration:pooling_func, Type: Categorical, Choices: {mean, median, max}, Default: mean feature_preprocessor:kernel_pca:coef0, Type: UniformFloat, Range: [-1.0, 1.0], Default: 0.0 feature_preprocessor:kernel_pca:degree, Type: UniformInteger, Range: [2, 5], Default: 3 feature_preprocessor:kernel_pca:gamma, Type: UniformFloat, Range: [3.0517578125e-05, 8.0], Default: 0.01, on log-scale feature_preprocessor:kernel_pca:kernel, Type: Categorical, Choices: {poly, rbf, sigmoid, cosine}, Default: rbf feature_preprocessor:kernel_pca:n_components, Type: UniformInteger, Range: [10, 2000], Default: 100 feature_preprocessor:kitchen_sinks:gamma, Type: UniformFloat, Range: [3.0517578125e-05, 8.0], Default: 1.0, on log-scale feature_preprocessor:kitchen_sinks:n_components, Type: UniformInteger, Range: [50, 10000], Default: 100, on log-scale feature_preprocessor:liblinear_svc_preprocessor:C, Type: UniformFloat, Range: [0.03125, 32768.0], Default: 1.0, on log-scale feature_preprocessor:liblinear_svc_preprocessor:dual, Type: Constant, Value: False feature_preprocessor:liblinear_svc_preprocessor:fit_intercept, Type: Constant, Value: True feature_preprocessor:liblinear_svc_preprocessor:intercept_scaling, Type: Constant, Value: 1 feature_preprocessor:liblinear_svc_preprocessor:loss, Type: Categorical, Choices: {hinge, squared_hinge}, Default: squared_hinge feature_preprocessor:liblinear_svc_preprocessor:multi_class, Type: Constant, Value: ovr feature_preprocessor:liblinear_svc_preprocessor:penalty, Type: Constant, Value: l1 feature_preprocessor:liblinear_svc_preprocessor:tol, Type: UniformFloat, Range: [1e-05, 0.1], Default: 0.0001, on log-scale feature_preprocessor:nystroem_sampler:coef0, Type: UniformFloat, Range: [-1.0, 1.0], Default: 0.0 feature_preprocessor:nystroem_sampler:degree, Type: UniformInteger, Range: [2, 5], Default: 3 feature_preprocessor:nystroem_sampler:gamma, Type: UniformFloat, Range: [3.0517578125e-05, 8.0], Default: 0.1, on log-scale feature_preprocessor:nystroem_sampler:kernel, Type: Categorical, Choices: {poly, rbf, sigmoid, cosine}, Default: rbf feature_preprocessor:nystroem_sampler:n_components, Type: UniformInteger, Range: [50, 10000], Default: 100, on log-scale feature_preprocessor:pca:keep_variance, Type: UniformFloat, Range: [0.5, 0.9999], Default: 0.9999 feature_preprocessor:pca:whiten, Type: Categorical, Choices: {False, True}, Default: False feature_preprocessor:polynomial:degree, Type: UniformInteger, Range: [2, 3], Default: 2 feature_preprocessor:polynomial:include_bias, Type: Categorical, Choices: {True, False}, Default: True feature_preprocessor:polynomial:interaction_only, Type: Categorical, Choices: {False, True}, Default: False feature_preprocessor:random_trees_embedding:bootstrap, Type: Categorical, Choices: {True, False}, Default: True feature_preprocessor:random_trees_embedding:max_depth, Type: UniformInteger, Range: [2, 10], Default: 5 feature_preprocessor:random_trees_embedding:max_leaf_nodes, Type: Constant, Value: None feature_preprocessor:random_trees_embedding:min_samples_leaf, Type: UniformInteger, Range: [1, 20], Default: 1 feature_preprocessor:random_trees_embedding:min_samples_split, Type: UniformInteger, Range: [2, 20], Default: 2 feature_preprocessor:random_trees_embedding:min_weight_fraction_leaf, Type: Constant, Value: 1.0 feature_preprocessor:random_trees_embedding:n_estimators, Type: UniformInteger, Range: [10, 100], Default: 10 feature_preprocessor:select_percentile_classification:percentile, Type: UniformFloat, Range: [1.0, 99.0], Default: 50.0 feature_preprocessor:select_percentile_classification:score_func, Type: Categorical, Choices: {chi2, f_classif, mutual_info}, Default: chi2 feature_preprocessor:select_rates_classification:alpha, Type: UniformFloat, Range: [0.01, 0.5], Default: 0.1 feature_preprocessor:select_rates_classification:mode, Type: Categorical, Choices: {fpr, fdr, fwe}, Default: fpr feature_preprocessor:select_rates_classification:score_func, Type: Categorical, Choices: {chi2, f_classif, mutual_info_classif}, Default: chi2 Conditions: classifier:CustomRandomForest:max_features | classifier:__choice__ == 'CustomRandomForest' classifier:CustomRandomForest:n_estimators | classifier:__choice__ == 'CustomRandomForest' classifier:adaboost:algorithm | classifier:__choice__ == 'adaboost' classifier:adaboost:learning_rate | classifier:__choice__ == 'adaboost' classifier:adaboost:max_depth | classifier:__choice__ == 'adaboost' classifier:adaboost:n_estimators | classifier:__choice__ == 'adaboost' classifier:bernoulli_nb:alpha | classifier:__choice__ == 'bernoulli_nb' classifier:bernoulli_nb:fit_prior | classifier:__choice__ == 'bernoulli_nb' classifier:decision_tree:criterion | classifier:__choice__ == 'decision_tree' classifier:decision_tree:max_depth_factor | classifier:__choice__ == 'decision_tree' classifier:decision_tree:max_features | classifier:__choice__ == 'decision_tree' classifier:decision_tree:max_leaf_nodes | classifier:__choice__ == 'decision_tree' classifier:decision_tree:min_impurity_decrease | classifier:__choice__ == 'decision_tree' classifier:decision_tree:min_samples_leaf | classifier:__choice__ == 'decision_tree' classifier:decision_tree:min_samples_split | classifier:__choice__ == 'decision_tree' classifier:decision_tree:min_weight_fraction_leaf | classifier:__choice__ == 'decision_tree' classifier:extra_trees:bootstrap | classifier:__choice__ == 'extra_trees' classifier:extra_trees:criterion | classifier:__choice__ == 'extra_trees' classifier:extra_trees:max_depth | classifier:__choice__ == 'extra_trees' classifier:extra_trees:max_features | classifier:__choice__ == 'extra_trees' classifier:extra_trees:max_leaf_nodes | classifier:__choice__ == 'extra_trees' classifier:extra_trees:min_impurity_decrease | classifier:__choice__ == 'extra_trees' classifier:extra_trees:min_samples_leaf | classifier:__choice__ == 'extra_trees' classifier:extra_trees:min_samples_split | classifier:__choice__ == 'extra_trees' classifier:extra_trees:min_weight_fraction_leaf | classifier:__choice__ == 'extra_trees' classifier:gradient_boosting:early_stop | classifier:__choice__ == 'gradient_boosting' classifier:gradient_boosting:l2_regularization | classifier:__choice__ == 'gradient_boosting' classifier:gradient_boosting:learning_rate | classifier:__choice__ == 'gradient_boosting' classifier:gradient_boosting:loss | classifier:__choice__ == 'gradient_boosting' classifier:gradient_boosting:max_bins | classifier:__choice__ == 'gradient_boosting' classifier:gradient_boosting:max_depth | classifier:__choice__ == 'gradient_boosting' classifier:gradient_boosting:max_leaf_nodes | classifier:__choice__ == 'gradient_boosting' classifier:gradient_boosting:min_samples_leaf | classifier:__choice__ == 'gradient_boosting' classifier:gradient_boosting:n_iter_no_change | classifier:gradient_boosting:early_stop in {'valid', 'train'} classifier:gradient_boosting:scoring | classifier:__choice__ == 'gradient_boosting' classifier:gradient_boosting:tol | classifier:__choice__ == 'gradient_boosting' classifier:gradient_boosting:validation_fraction | classifier:gradient_boosting:early_stop == 'valid' classifier:k_nearest_neighbors:n_neighbors | classifier:__choice__ == 'k_nearest_neighbors' classifier:k_nearest_neighbors:p | classifier:__choice__ == 'k_nearest_neighbors' classifier:k_nearest_neighbors:weights | classifier:__choice__ == 'k_nearest_neighbors' classifier:lda:shrinkage | classifier:__choice__ == 'lda' classifier:lda:shrinkage_factor | classifier:lda:shrinkage == 'manual' classifier:lda:tol | classifier:__choice__ == 'lda' classifier:liblinear_svc:C | classifier:__choice__ == 'liblinear_svc' classifier:liblinear_svc:dual | classifier:__choice__ == 'liblinear_svc' classifier:liblinear_svc:fit_intercept | classifier:__choice__ == 'liblinear_svc' classifier:liblinear_svc:intercept_scaling | classifier:__choice__ == 'liblinear_svc' classifier:liblinear_svc:loss | classifier:__choice__ == 'liblinear_svc' classifier:liblinear_svc:multi_class | classifier:__choice__ == 'liblinear_svc' classifier:liblinear_svc:penalty | classifier:__choice__ == 'liblinear_svc' classifier:liblinear_svc:tol | classifier:__choice__ == 'liblinear_svc' classifier:libsvm_svc:C | classifier:__choice__ == 'libsvm_svc' classifier:libsvm_svc:coef0 | classifier:libsvm_svc:kernel in {'poly', 'sigmoid'} classifier:libsvm_svc:degree | classifier:libsvm_svc:kernel == 'poly' classifier:libsvm_svc:gamma | classifier:__choice__ == 'libsvm_svc' classifier:libsvm_svc:kernel | classifier:__choice__ == 'libsvm_svc' classifier:libsvm_svc:max_iter | classifier:__choice__ == 'libsvm_svc' classifier:libsvm_svc:shrinking | classifier:__choice__ == 'libsvm_svc' classifier:libsvm_svc:tol | classifier:__choice__ == 'libsvm_svc' classifier:mlp:activation | classifier:__choice__ == 'mlp' classifier:mlp:alpha | classifier:__choice__ == 'mlp' classifier:mlp:batch_size | classifier:__choice__ == 'mlp' classifier:mlp:beta_1 | classifier:__choice__ == 'mlp' classifier:mlp:beta_2 | classifier:__choice__ == 'mlp' classifier:mlp:early_stopping | classifier:__choice__ == 'mlp' classifier:mlp:epsilon | classifier:__choice__ == 'mlp' classifier:mlp:hidden_layer_depth | classifier:__choice__ == 'mlp' classifier:mlp:learning_rate_init | classifier:__choice__ == 'mlp' classifier:mlp:n_iter_no_change | classifier:__choice__ == 'mlp' classifier:mlp:num_nodes_per_layer | classifier:__choice__ == 'mlp' classifier:mlp:shuffle | classifier:__choice__ == 'mlp' classifier:mlp:solver | classifier:__choice__ == 'mlp' classifier:mlp:tol | classifier:__choice__ == 'mlp' classifier:mlp:validation_fraction | classifier:mlp:early_stopping in {'valid'} classifier:multinomial_nb:alpha | classifier:__choice__ == 'multinomial_nb' classifier:multinomial_nb:fit_prior | classifier:__choice__ == 'multinomial_nb' classifier:passive_aggressive:C | classifier:__choice__ == 'passive_aggressive' classifier:passive_aggressive:average | classifier:__choice__ == 'passive_aggressive' classifier:passive_aggressive:fit_intercept | classifier:__choice__ == 'passive_aggressive' classifier:passive_aggressive:loss | classifier:__choice__ == 'passive_aggressive' classifier:passive_aggressive:tol | classifier:__choice__ == 'passive_aggressive' classifier:qda:reg_param | classifier:__choice__ == 'qda' classifier:sgd:alpha | classifier:__choice__ == 'sgd' classifier:sgd:average | classifier:__choice__ == 'sgd' classifier:sgd:epsilon | classifier:sgd:loss == 'modified_huber' classifier:sgd:eta0 | classifier:sgd:learning_rate in {'invscaling', 'constant'} classifier:sgd:fit_intercept | classifier:__choice__ == 'sgd' classifier:sgd:l1_ratio | classifier:sgd:penalty == 'elasticnet' classifier:sgd:learning_rate | classifier:__choice__ == 'sgd' classifier:sgd:loss | classifier:__choice__ == 'sgd' classifier:sgd:penalty | classifier:__choice__ == 'sgd' classifier:sgd:power_t | classifier:sgd:learning_rate == 'invscaling' classifier:sgd:tol | classifier:__choice__ == 'sgd' data_preprocessor:feature_type:numerical_transformer:imputation:strategy | data_preprocessor:__choice__ == 'feature_type' data_preprocessor:feature_type:numerical_transformer:rescaling:__choice__ | data_preprocessor:__choice__ == 'feature_type' data_preprocessor:feature_type:numerical_transformer:rescaling:quantile_transformer:n_quantiles | data_preprocessor:feature_type:numerical_transformer:rescaling:__choice__ == 'quantile_transformer' data_preprocessor:feature_type:numerical_transformer:rescaling:quantile_transformer:output_distribution | data_preprocessor:feature_type:numerical_transformer:rescaling:__choice__ == 'quantile_transformer' data_preprocessor:feature_type:numerical_transformer:rescaling:robust_scaler:q_max | data_preprocessor:feature_type:numerical_transformer:rescaling:__choice__ == 'robust_scaler' data_preprocessor:feature_type:numerical_transformer:rescaling:robust_scaler:q_min | data_preprocessor:feature_type:numerical_transformer:rescaling:__choice__ == 'robust_scaler' feature_preprocessor:LDA:shrinkage | feature_preprocessor:LDA:solver in {'lsqr', 'eigen'} feature_preprocessor:LDA:solver | feature_preprocessor:__choice__ == 'LDA' feature_preprocessor:LDA:tol | feature_preprocessor:__choice__ == 'LDA' feature_preprocessor:extra_trees_preproc_for_classification:bootstrap | feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' feature_preprocessor:extra_trees_preproc_for_classification:criterion | feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' feature_preprocessor:extra_trees_preproc_for_classification:max_depth | feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' feature_preprocessor:extra_trees_preproc_for_classification:max_features | feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' feature_preprocessor:extra_trees_preproc_for_classification:max_leaf_nodes | feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' feature_preprocessor:extra_trees_preproc_for_classification:min_impurity_decrease | feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' feature_preprocessor:extra_trees_preproc_for_classification:min_samples_leaf | feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' feature_preprocessor:extra_trees_preproc_for_classification:min_samples_split | feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' feature_preprocessor:extra_trees_preproc_for_classification:min_weight_fraction_leaf | feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' feature_preprocessor:extra_trees_preproc_for_classification:n_estimators | feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' feature_preprocessor:fast_ica:algorithm | feature_preprocessor:__choice__ == 'fast_ica' feature_preprocessor:fast_ica:fun | feature_preprocessor:__choice__ == 'fast_ica' feature_preprocessor:fast_ica:n_components | feature_preprocessor:fast_ica:whiten == 'True' feature_preprocessor:fast_ica:whiten | feature_preprocessor:__choice__ == 'fast_ica' feature_preprocessor:feature_agglomeration:affinity | feature_preprocessor:__choice__ == 'feature_agglomeration' feature_preprocessor:feature_agglomeration:linkage | feature_preprocessor:__choice__ == 'feature_agglomeration' feature_preprocessor:feature_agglomeration:n_clusters | feature_preprocessor:__choice__ == 'feature_agglomeration' feature_preprocessor:feature_agglomeration:pooling_func | feature_preprocessor:__choice__ == 'feature_agglomeration' feature_preprocessor:kernel_pca:coef0 | feature_preprocessor:kernel_pca:kernel in {'poly', 'sigmoid'} feature_preprocessor:kernel_pca:degree | feature_preprocessor:kernel_pca:kernel == 'poly' feature_preprocessor:kernel_pca:gamma | feature_preprocessor:kernel_pca:kernel in {'poly', 'rbf'} feature_preprocessor:kernel_pca:kernel | feature_preprocessor:__choice__ == 'kernel_pca' feature_preprocessor:kernel_pca:n_components | feature_preprocessor:__choice__ == 'kernel_pca' feature_preprocessor:kitchen_sinks:gamma | feature_preprocessor:__choice__ == 'kitchen_sinks' feature_preprocessor:kitchen_sinks:n_components | feature_preprocessor:__choice__ == 'kitchen_sinks' feature_preprocessor:liblinear_svc_preprocessor:C | feature_preprocessor:__choice__ == 'liblinear_svc_preprocessor' feature_preprocessor:liblinear_svc_preprocessor:dual | feature_preprocessor:__choice__ == 'liblinear_svc_preprocessor' feature_preprocessor:liblinear_svc_preprocessor:fit_intercept | feature_preprocessor:__choice__ == 'liblinear_svc_preprocessor' feature_preprocessor:liblinear_svc_preprocessor:intercept_scaling | feature_preprocessor:__choice__ == 'liblinear_svc_preprocessor' feature_preprocessor:liblinear_svc_preprocessor:loss | feature_preprocessor:__choice__ == 'liblinear_svc_preprocessor' feature_preprocessor:liblinear_svc_preprocessor:multi_class | feature_preprocessor:__choice__ == 'liblinear_svc_preprocessor' feature_preprocessor:liblinear_svc_preprocessor:penalty | feature_preprocessor:__choice__ == 'liblinear_svc_preprocessor' feature_preprocessor:liblinear_svc_preprocessor:tol | feature_preprocessor:__choice__ == 'liblinear_svc_preprocessor' feature_preprocessor:nystroem_sampler:coef0 | feature_preprocessor:nystroem_sampler:kernel in {'poly', 'sigmoid'} feature_preprocessor:nystroem_sampler:degree | feature_preprocessor:nystroem_sampler:kernel == 'poly' feature_preprocessor:nystroem_sampler:gamma | feature_preprocessor:nystroem_sampler:kernel in {'poly', 'rbf', 'sigmoid'} feature_preprocessor:nystroem_sampler:kernel | feature_preprocessor:__choice__ == 'nystroem_sampler' feature_preprocessor:nystroem_sampler:n_components | feature_preprocessor:__choice__ == 'nystroem_sampler' feature_preprocessor:pca:keep_variance | feature_preprocessor:__choice__ == 'pca' feature_preprocessor:pca:whiten | feature_preprocessor:__choice__ == 'pca' feature_preprocessor:polynomial:degree | feature_preprocessor:__choice__ == 'polynomial' feature_preprocessor:polynomial:include_bias | feature_preprocessor:__choice__ == 'polynomial' feature_preprocessor:polynomial:interaction_only | feature_preprocessor:__choice__ == 'polynomial' feature_preprocessor:random_trees_embedding:bootstrap | feature_preprocessor:__choice__ == 'random_trees_embedding' feature_preprocessor:random_trees_embedding:max_depth | feature_preprocessor:__choice__ == 'random_trees_embedding' feature_preprocessor:random_trees_embedding:max_leaf_nodes | feature_preprocessor:__choice__ == 'random_trees_embedding' feature_preprocessor:random_trees_embedding:min_samples_leaf | feature_preprocessor:__choice__ == 'random_trees_embedding' feature_preprocessor:random_trees_embedding:min_samples_split | feature_preprocessor:__choice__ == 'random_trees_embedding' feature_preprocessor:random_trees_embedding:min_weight_fraction_leaf | feature_preprocessor:__choice__ == 'random_trees_embedding' feature_preprocessor:random_trees_embedding:n_estimators | feature_preprocessor:__choice__ == 'random_trees_embedding' feature_preprocessor:select_percentile_classification:percentile | feature_preprocessor:__choice__ == 'select_percentile_classification' feature_preprocessor:select_percentile_classification:score_func | feature_preprocessor:__choice__ == 'select_percentile_classification' feature_preprocessor:select_rates_classification:alpha | feature_preprocessor:__choice__ == 'select_rates_classification' feature_preprocessor:select_rates_classification:mode | feature_preprocessor:select_rates_classification:score_func != 'mutual_info_classif' feature_preprocessor:select_rates_classification:score_func | feature_preprocessor:__choice__ == 'select_rates_classification' Forbidden Clauses: (Forbidden: feature_preprocessor:feature_agglomeration:affinity in {'cosine', 'manhattan'} && Forbidden: feature_preprocessor:feature_agglomeration:linkage == 'ward') (Forbidden: feature_preprocessor:liblinear_svc_preprocessor:penalty == 'l1' && Forbidden: feature_preprocessor:liblinear_svc_preprocessor:loss == 'hinge') (Forbidden: classifier:liblinear_svc:penalty == 'l1' && Forbidden: classifier:liblinear_svc:loss == 'hinge') (Forbidden: classifier:liblinear_svc:dual == 'False' && Forbidden: classifier:liblinear_svc:penalty == 'l2' && Forbidden: classifier:liblinear_svc:loss == 'hinge') (Forbidden: classifier:liblinear_svc:dual == 'False' && Forbidden: classifier:liblinear_svc:penalty == 'l1') (Forbidden: feature_preprocessor:__choice__ == 'extra_trees_preproc_for_classification' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'fast_ica' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'feature_agglomeration' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'kernel_pca' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'kitchen_sinks' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'liblinear_svc_preprocessor' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'no_preprocessing' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'nystroem_sampler' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'pca' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'polynomial' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'random_trees_embedding' && Forbidden: classifier:__choice__ == 'gaussian_nb') (Forbidden: feature_preprocessor:__choice__ == 'random_trees_embedding' && Forbidden: classifier:__choice__ == 'gradient_boosting') (Forbidden: feature_preprocessor:__choice__ == 'random_trees_embedding' && Forbidden: classifier:__choice__ == 'lda') (Forbidden: feature_preprocessor:__choice__ == 'random_trees_embedding' && Forbidden: classifier:__choice__ == 'qda') (Forbidden: feature_preprocessor:__choice__ == 'select_percentile_classification' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'select_rates_classification' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: classifier:__choice__ == 'adaboost' && Forbidden: feature_preprocessor:__choice__ == 'kernel_pca') (Forbidden: classifier:__choice__ == 'adaboost' && Forbidden: feature_preprocessor:__choice__ == 'kitchen_sinks') (Forbidden: classifier:__choice__ == 'adaboost' && Forbidden: feature_preprocessor:__choice__ == 'nystroem_sampler') (Forbidden: classifier:__choice__ == 'decision_tree' && Forbidden: feature_preprocessor:__choice__ == 'kernel_pca') (Forbidden: classifier:__choice__ == 'decision_tree' && Forbidden: feature_preprocessor:__choice__ == 'kitchen_sinks') (Forbidden: classifier:__choice__ == 'decision_tree' && Forbidden: feature_preprocessor:__choice__ == 'nystroem_sampler') (Forbidden: classifier:__choice__ == 'extra_trees' && Forbidden: feature_preprocessor:__choice__ == 'kernel_pca') (Forbidden: classifier:__choice__ == 'extra_trees' && Forbidden: feature_preprocessor:__choice__ == 'kitchen_sinks') (Forbidden: classifier:__choice__ == 'extra_trees' && Forbidden: feature_preprocessor:__choice__ == 'nystroem_sampler') (Forbidden: classifier:__choice__ == 'gradient_boosting' && Forbidden: feature_preprocessor:__choice__ == 'kernel_pca') (Forbidden: classifier:__choice__ == 'gradient_boosting' && Forbidden: feature_preprocessor:__choice__ == 'kitchen_sinks') (Forbidden: classifier:__choice__ == 'gradient_boosting' && Forbidden: feature_preprocessor:__choice__ == 'nystroem_sampler') (Forbidden: classifier:__choice__ == 'k_nearest_neighbors' && Forbidden: feature_preprocessor:__choice__ == 'kernel_pca') (Forbidden: classifier:__choice__ == 'k_nearest_neighbors' && Forbidden: feature_preprocessor:__choice__ == 'kitchen_sinks') (Forbidden: classifier:__choice__ == 'k_nearest_neighbors' && Forbidden: feature_preprocessor:__choice__ == 'nystroem_sampler') (Forbidden: classifier:__choice__ == 'libsvm_svc' && Forbidden: feature_preprocessor:__choice__ == 'kernel_pca') (Forbidden: classifier:__choice__ == 'libsvm_svc' && Forbidden: feature_preprocessor:__choice__ == 'kitchen_sinks') (Forbidden: classifier:__choice__ == 'libsvm_svc' && Forbidden: feature_preprocessor:__choice__ == 'nystroem_sampler') (Forbidden: classifier:__choice__ == 'mlp' && Forbidden: feature_preprocessor:__choice__ == 'kernel_pca') (Forbidden: classifier:__choice__ == 'mlp' && Forbidden: feature_preprocessor:__choice__ == 'kitchen_sinks') (Forbidden: classifier:__choice__ == 'mlp' && Forbidden: feature_preprocessor:__choice__ == 'nystroem_sampler') (Forbidden: classifier:__choice__ == 'gaussian_nb' && Forbidden: feature_preprocessor:__choice__ == 'kernel_pca') (Forbidden: classifier:__choice__ == 'gaussian_nb' && Forbidden: feature_preprocessor:__choice__ == 'kitchen_sinks') (Forbidden: classifier:__choice__ == 'gaussian_nb' && Forbidden: feature_preprocessor:__choice__ == 'nystroem_sampler') (Forbidden: feature_preprocessor:__choice__ == 'kitchen_sinks' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'pca' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'fast_ica' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'kernel_pca' && Forbidden: classifier:__choice__ == 'multinomial_nb') (Forbidden: feature_preprocessor:__choice__ == 'nystroem_sampler' && Forbidden: classifier:__choice__ == 'multinomial_nb') .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 9.951 seconds) .. _sphx_glr_download_examples_80_extending_example_restrict_number_of_hyperparameters.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/automl/auto-sklearn/master?urlpath=lab/tree/notebooks/examples/80_extending/example_restrict_number_of_hyperparameters.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_restrict_number_of_hyperparameters.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_restrict_number_of_hyperparameters.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_