Skip to content

Commit 5208dc2

Browse files
author
Github Actions
committed
Sagar Kaushik: Changes show_models() function to return a dictionary of models in ensemble (#1321)
1 parent 6e225a8 commit 5208dc2

File tree

107 files changed

+4945
-3548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+4945
-3548
lines changed

development/_downloads/16fb4037a0b549292dbf3df70af70372/example_classification.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"import sklearn.datasets\nimport sklearn.metrics\n\nimport autosklearn.classification"
29+
"from pprint import pprint\n\nimport sklearn.datasets\nimport sklearn.metrics\n\nimport autosklearn.classification"
3030
]
3131
},
3232
{
@@ -98,7 +98,7 @@
9898
},
9999
"outputs": [],
100100
"source": [
101-
"print(automl.show_models())"
101+
"pprint(automl.show_models(), indent=4)"
102102
]
103103
},
104104
{

development/_downloads/1a053e45a20a2c15032411b9fee890a3/example_sequential.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
sequentially. The example below shows how to first fit the models and build the
99
ensembles afterwards.
1010
"""
11+
from pprint import pprint
1112

1213
import sklearn.model_selection
1314
import sklearn.datasets
@@ -48,7 +49,7 @@
4849
# Print the final ensemble constructed by auto-sklearn
4950
# ====================================================
5051

51-
print(automl.show_models())
52+
pprint(automl.show_models(), indent=4)
5253

5354
############################################################################
5455
# Get the Score of the final ensemble

development/_downloads/23ae4950352edc8dd9ea5443ba77886b/example_extending_regression.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
The following example demonstrates how to create a new regression
77
component for using in auto-sklearn.
88
"""
9+
from pprint import pprint
910

1011
from ConfigSpace.configuration_space import ConfigurationSpace
1112
from ConfigSpace.hyperparameters import UniformFloatHyperparameter, \
@@ -137,4 +138,4 @@ def get_hyperparameter_search_space(dataset_properties=None):
137138
# =====================================
138139
y_pred = reg.predict(X_test)
139140
print("r2 score: ", sklearn.metrics.r2_score(y_pred, y_test))
140-
print(reg.show_models())
141+
pprint(reg.show_models(), indent=4)

development/_downloads/2991959d1e025c5f9f27e3b4d3265a81/example_multilabel_classification.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"import numpy as np\n\nimport sklearn.datasets\nimport sklearn.metrics\nfrom sklearn.utils.multiclass import type_of_target\n\nimport autosklearn.classification"
29+
"import numpy as np\nfrom pprint import pprint\n\nimport sklearn.datasets\nimport sklearn.metrics\nfrom sklearn.utils.multiclass import type_of_target\n\nimport autosklearn.classification"
3030
]
3131
},
3232
{
@@ -98,7 +98,7 @@
9898
},
9999
"outputs": [],
100100
"source": [
101-
"print(automl.show_models())"
101+
"pprint(automl.show_models(), indent=4)"
102102
]
103103
},
104104
{

development/_downloads/2f293025f5b75af329925f2c3ff58c06/example_sequential.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"import sklearn.model_selection\nimport sklearn.datasets\nimport sklearn.metrics\n\nimport autosklearn.classification"
29+
"from pprint import pprint\n\nimport sklearn.model_selection\nimport sklearn.datasets\nimport sklearn.metrics\n\nimport autosklearn.classification"
3030
]
3131
},
3232
{
@@ -80,7 +80,7 @@
8080
},
8181
"outputs": [],
8282
"source": [
83-
"print(automl.show_models())"
83+
"pprint(automl.show_models(), indent=4)"
8484
]
8585
},
8686
{

development/_downloads/34d1d3a5e629625f2f22f39d7c3a650e/example_interpretable_models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
The following example shows how to inspect the models which *auto-sklearn*
88
optimizes over and how to restrict them to an interpretable subset.
99
"""
10+
from pprint import pprint
11+
1012
import autosklearn.classification
1113
import sklearn.datasets
1214
import sklearn.metrics
@@ -70,7 +72,7 @@
7072
# Print the final ensemble constructed by auto-sklearn
7173
# ====================================================
7274

73-
print(automl.show_models())
75+
pprint(automl.show_models(), indent=4)
7476

7577
###########################################################################
7678
# Get the Score of the final ensemble

development/_downloads/42784b4d4739b840b1eeb6159bf08f4e/example_regression.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
The following example shows how to fit a simple regression model with
88
*auto-sklearn*.
99
"""
10+
from pprint import pprint
11+
1012
import sklearn.datasets
1113
import sklearn.metrics
1214

@@ -43,7 +45,7 @@
4345
# Print the final ensemble constructed by auto-sklearn
4446
# ====================================================
4547

46-
print(automl.show_models())
48+
pprint(automl.show_models(), indent=4)
4749

4850
#####################################
4951
# Get the Score of the final ensemble

development/_downloads/49577cbea6f814a2c9a5167f35be2814/example_multioutput_regression.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*auto-sklearn*.
99
"""
1010
import numpy as numpy
11+
from pprint import pprint
1112

1213
from sklearn.datasets import make_regression
1314
from sklearn.metrics import r2_score
@@ -46,7 +47,7 @@
4647
# Print the final ensemble constructed by auto-sklearn
4748
# ====================================================
4849

49-
print(automl.show_models())
50+
pprint(automl.show_models(), indent=4)
5051

5152
###########################################################################
5253
# Get the Score of the final ensemble

development/_downloads/515ab036d01801cb08e4878be1aef556/example_extending_classification.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
The following example demonstrates how to create a new classification
77
component for using in auto-sklearn.
88
"""
9+
from pprint import pprint
910

1011
from ConfigSpace.configuration_space import ConfigurationSpace
1112
from ConfigSpace.hyperparameters import CategoricalHyperparameter, \
@@ -149,4 +150,4 @@ def get_hyperparameter_search_space(dataset_properties=None):
149150

150151
y_pred = clf.predict(X_test)
151152
print("accuracy: ", sklearn.metrics.accuracy_score(y_pred, y_test))
152-
print(clf.show_models())
153+
pprint(clf.show_models(), indent=4)

development/_downloads/54625156807f9d21fa14b78034b1df5c/example_successive_halving.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
To get the BOHB algorithm, simply import Hyperband and use it as the intensification strategy.
1515
1616
""" # noqa (links are too long)
17-
17+
from pprint import pprint
1818

1919
import sklearn.model_selection
2020
import sklearn.datasets
@@ -110,7 +110,7 @@ def get_smac_object(
110110
)
111111
automl.fit(X_train, y_train, dataset_name='breast_cancer')
112112

113-
print(automl.show_models())
113+
pprint(automl.show_models(), indent=4)
114114
predictions = automl.predict(X_test)
115115
# Print statistics about the auto-sklearn run such as number of
116116
# iterations, number of models failed with a time out.
@@ -143,7 +143,7 @@ def get_smac_object(
143143
automl.fit(X_train, y_train, dataset_name='breast_cancer')
144144

145145
# Print the final ensemble constructed by auto-sklearn.
146-
print(automl.show_models())
146+
pprint(automl.show_models(), indent=4)
147147
automl.refit(X_train, y_train)
148148
predictions = automl.predict(X_test)
149149
# Print statistics about the auto-sklearn run such as number of
@@ -177,7 +177,7 @@ def get_smac_object(
177177
automl.fit(X_train, y_train, dataset_name='breast_cancer')
178178

179179
# Print the final ensemble constructed by auto-sklearn.
180-
print(automl.show_models())
180+
pprint(automl.show_models(), indent=4)
181181
automl.refit(X_train, y_train)
182182
predictions = automl.predict(X_test)
183183
# Print statistics about the auto-sklearn run such as number of
@@ -208,7 +208,7 @@ def get_smac_object(
208208
automl.fit(X_train, y_train, dataset_name='breast_cancer')
209209

210210
# Print the final ensemble constructed by auto-sklearn.
211-
print(automl.show_models())
211+
pprint(automl.show_models(), indent=4)
212212
predictions = automl.predict(X_test)
213213
# Print statistics about the auto-sklearn run such as number of
214214
# iterations, number of models failed with a time out.
@@ -245,7 +245,7 @@ def get_smac_object(
245245
automl.fit(X_train, y_train, dataset_name='breast_cancer')
246246

247247
# Print the final ensemble constructed by auto-sklearn.
248-
print(automl.show_models())
248+
pprint(automl.show_models(), indent=4)
249249
predictions = automl.predict(X_test)
250250
# Print statistics about the auto-sklearn run such as number of
251251
# iterations, number of models failed with a time out.

development/_downloads/5f58bfc8fd90dc731fa26fb9996d2aa5/example_interpretable_models.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"import autosklearn.classification\nimport sklearn.datasets\nimport sklearn.metrics"
29+
"from pprint import pprint\n\nimport autosklearn.classification\nimport sklearn.datasets\nimport sklearn.metrics"
3030
]
3131
},
3232
{
@@ -116,7 +116,7 @@
116116
},
117117
"outputs": [],
118118
"source": [
119-
"print(automl.show_models())"
119+
"pprint(automl.show_models(), indent=4)"
120120
]
121121
},
122122
{

development/_downloads/60abb5e0c4b0861f5ecbe4ae9c2e51dd/example_extending_data_preprocessor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
The following example demonstrates how to turn off data preprocessing step in auto-skearn.
77
"""
8+
from pprint import pprint
89

910
import autosklearn.classification
1011
import autosklearn.pipeline.components.data_preprocessing
@@ -89,4 +90,4 @@ def get_hyperparameter_search_space(dataset_properties=None):
8990

9091
y_pred = clf.predict(X_test)
9192
print("accuracy: ", sklearn.metrics.accuracy_score(y_pred, y_test))
92-
print(clf.show_models())
93+
pprint(clf.show_models(), indent=4)

development/_downloads/650cd19a8dfee813a7d7fb5b90341ed3/example_classification.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
The following example shows how to fit a simple classification model with
88
*auto-sklearn*.
99
"""
10+
from pprint import pprint
11+
1012
import sklearn.datasets
1113
import sklearn.metrics
1214

@@ -42,7 +44,7 @@
4244
# Print the final ensemble constructed by auto-sklearn
4345
# ====================================================
4446

45-
print(automl.show_models())
47+
pprint(automl.show_models(), indent=4)
4648

4749
###########################################################################
4850
# Get the Score of the final ensemble

development/_downloads/6dea5849db1f35abbefe123cd0eb49fd/example_extending_data_preprocessor.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"import autosklearn.classification\nimport autosklearn.pipeline.components.data_preprocessing\nimport sklearn.metrics\nfrom ConfigSpace.configuration_space import ConfigurationSpace\nfrom autosklearn.pipeline.components.base import AutoSklearnPreprocessingAlgorithm\nfrom autosklearn.pipeline.constants import SPARSE, DENSE, UNSIGNED_DATA, INPUT\nfrom sklearn.datasets import load_breast_cancer\nfrom sklearn.model_selection import train_test_split"
29+
"from pprint import pprint\n\nimport autosklearn.classification\nimport autosklearn.pipeline.components.data_preprocessing\nimport sklearn.metrics\nfrom ConfigSpace.configuration_space import ConfigurationSpace\nfrom autosklearn.pipeline.components.base import AutoSklearnPreprocessingAlgorithm\nfrom autosklearn.pipeline.constants import SPARSE, DENSE, UNSIGNED_DATA, INPUT\nfrom sklearn.datasets import load_breast_cancer\nfrom sklearn.model_selection import train_test_split"
3030
]
3131
},
3232
{
@@ -98,7 +98,7 @@
9898
},
9999
"outputs": [],
100100
"source": [
101-
"y_pred = clf.predict(X_test)\nprint(\"accuracy: \", sklearn.metrics.accuracy_score(y_pred, y_test))\nprint(clf.show_models())"
101+
"y_pred = clf.predict(X_test)\nprint(\"accuracy: \", sklearn.metrics.accuracy_score(y_pred, y_test))\npprint(clf.show_models(), indent=4)"
102102
]
103103
}
104104
],

development/_downloads/77f2a85d2877495effe09ede1c7a1d31/example_regression.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"import sklearn.datasets\nimport sklearn.metrics\n\nimport autosklearn.regression\nimport matplotlib.pyplot as plt"
29+
"from pprint import pprint\n\nimport sklearn.datasets\nimport sklearn.metrics\n\nimport autosklearn.regression\nimport matplotlib.pyplot as plt"
3030
]
3131
},
3232
{
@@ -98,7 +98,7 @@
9898
},
9999
"outputs": [],
100100
"source": [
101-
"print(automl.show_models())"
101+
"pprint(automl.show_models(), indent=4)"
102102
]
103103
},
104104
{

development/_downloads/89647a1665eba015b7197cfe70420e4d/example_multilabel_classification.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
`here <https://scikit-learn.org/stable/modules/multiclass.html>`_.
99
"""
1010
import numpy as np
11+
from pprint import pprint
1112

1213
import sklearn.datasets
1314
import sklearn.metrics
@@ -65,7 +66,7 @@
6566
# Print the final ensemble constructed by auto-sklearn
6667
# ====================================================
6768

68-
print(automl.show_models())
69+
pprint(automl.show_models(), indent=4)
6970

7071
############################################################################
7172
# Print statistics about the auto-sklearn run

development/_downloads/a23bc40b83b60b7e97a3eb188a82ad24/example_extending_preprocessor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
discriminant analysis (LDA) algorithm from sklearn and use it as a preprocessor
88
in auto-sklearn.
99
"""
10+
from pprint import pprint
1011

1112
from ConfigSpace.configuration_space import ConfigurationSpace
1213
from ConfigSpace.hyperparameters import UniformFloatHyperparameter, CategoricalHyperparameter
@@ -130,4 +131,4 @@ def get_hyperparameter_search_space(dataset_properties=None):
130131

131132
y_pred = clf.predict(X_test)
132133
print("accuracy: ", sklearn.metrics.accuracy_score(y_pred, y_test))
133-
print(clf.show_models())
134+
pprint(clf.show_models(), indent=4)

development/_downloads/a7f5a98ecf82e30e146cc9bfe484c397/example_get_pipeline_components.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"import sklearn.datasets\nimport sklearn.metrics\n\nimport autosklearn.classification"
29+
"from pprint import pprint\n\nimport sklearn.datasets\nimport sklearn.metrics\n\nimport autosklearn.classification"
3030
]
3131
},
3232
{
@@ -87,7 +87,7 @@
8787
"cell_type": "markdown",
8888
"metadata": {},
8989
"source": [
90-
"## Report the models found by Auto-Sklearn\n\nAuto-sklearn uses\n`Ensemble Selection <https://www.cs.cornell.edu/~alexn/papers/shotgun.icml04.revised.rev2.pdf>`_\nto construct ensembles in a post-hoc fashion. The ensemble is a linear\nweighting of all models constructed during the hyperparameter optimization.\nThis prints the final ensemble. It is a list of tuples, each tuple being\nthe model weight in the ensemble and the model itself.\n\n"
90+
"## Report the models found by Auto-Sklearn\n\nAuto-sklearn uses\n`Ensemble Selection <https://www.cs.cornell.edu/~alexn/papers/shotgun.icml04.revised.rev2.pdf>`_\nto construct ensembles in a post-hoc fashion. The ensemble is a linear\nweighting of all models constructed during the hyperparameter optimization.\nThis prints the final ensemble. It is a dictionary where ``model_id`` of\neach model is a key, and value is a dictionary containing information\nof that model. A model's dict contains its ``'model_id'``, ``'rank'``,\n``'cost'``, ``'ensemble_weight'``, and the model itself. The model is\ngiven by the ``'data_preprocessor'``, ``'feature_preprocessor'``,\n``'regressor'/'classifier'`` and ``'sklearn_regressor'/'sklearn_classifier'``\nentries. But for the ``'cv'`` resampling strategy, the same for each cv\nmodel is stored in the ``'estimators'`` list in the dict, along with the\n``'voting_model'``.\n\n"
9191
]
9292
},
9393
{
@@ -98,7 +98,7 @@
9898
},
9999
"outputs": [],
100100
"source": [
101-
"print(automl.show_models())"
101+
"pprint(automl.show_models(), indent=4)"
102102
]
103103
},
104104
{
Binary file not shown.

development/_downloads/c4ec137bb92db1e6b2219eb13818b898/example_extending_classification.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"from ConfigSpace.configuration_space import ConfigurationSpace\nfrom ConfigSpace.hyperparameters import CategoricalHyperparameter, \\\n UniformIntegerHyperparameter, UniformFloatHyperparameter\n\nimport sklearn.metrics\nimport autosklearn.classification\nimport autosklearn.pipeline.components.classification\nfrom autosklearn.pipeline.components.base \\\n import AutoSklearnClassificationAlgorithm\nfrom autosklearn.pipeline.constants import DENSE, SIGNED_DATA, UNSIGNED_DATA, \\\n PREDICTIONS\n\nfrom sklearn.datasets import load_breast_cancer\nfrom sklearn.model_selection import train_test_split"
29+
"from pprint import pprint\n\nfrom ConfigSpace.configuration_space import ConfigurationSpace\nfrom ConfigSpace.hyperparameters import CategoricalHyperparameter, \\\n UniformIntegerHyperparameter, UniformFloatHyperparameter\n\nimport sklearn.metrics\nimport autosklearn.classification\nimport autosklearn.pipeline.components.classification\nfrom autosklearn.pipeline.components.base \\\n import AutoSklearnClassificationAlgorithm\nfrom autosklearn.pipeline.constants import DENSE, SIGNED_DATA, UNSIGNED_DATA, \\\n PREDICTIONS\n\nfrom sklearn.datasets import load_breast_cancer\nfrom sklearn.model_selection import train_test_split"
3030
]
3131
},
3232
{
@@ -98,7 +98,7 @@
9898
},
9999
"outputs": [],
100100
"source": [
101-
"y_pred = clf.predict(X_test)\nprint(\"accuracy: \", sklearn.metrics.accuracy_score(y_pred, y_test))\nprint(clf.show_models())"
101+
"y_pred = clf.predict(X_test)\nprint(\"accuracy: \", sklearn.metrics.accuracy_score(y_pred, y_test))\npprint(clf.show_models(), indent=4)"
102102
]
103103
}
104104
],

0 commit comments

Comments
 (0)