Note
Click here to download the full example code
OpenML Run ExampleΒΆ
An example of an automated machine learning experiment.
import openml
from sklearn import tree, preprocessing, pipeline
Warning
This example uploads data. For that reason, this example connects to the test server at test.openml.org. This prevents the main server from crowding with example datasets, tasks, runs, and so on.
openml.config.start_using_configuration_for_example()
# Uncomment and set your OpenML key. Don't share your key with others.
# openml.config.apikey = 'YOURKEY'
# Define a scikit-learn pipeline
clf = pipeline.Pipeline(
steps=[
('imputer', preprocessing.Imputer()),
('estimator', tree.DecisionTreeClassifier())
]
)
Out:
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
Download the OpenML task for the german credit card dataset.
task = openml.tasks.get_task(97)
Run the scikit-learn model on the task (requires an API key).
run = openml.runs.run_model_on_task(clf, task)
# Publish the experiment on OpenML (optional, requires an API key).
run.publish()
print('URL for run: %s/run/%d' % (openml.config.server, run.run_id))
Out:
I0703 12:38:52.434911 139733218952960 functions.py:432] Going to execute flow 'sklearn.pipeline.Pipeline(imputer=sklearn.preprocessing.imputation.Imputer,estimator=sklearn.tree.tree.DecisionTreeClassifier)' on task 97 for repeat 0 fold 0 sample 0.
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
I0703 12:38:52.488517 139733218952960 functions.py:432] Going to execute flow 'sklearn.pipeline.Pipeline(imputer=sklearn.preprocessing.imputation.Imputer,estimator=sklearn.tree.tree.DecisionTreeClassifier)' on task 97 for repeat 0 fold 1 sample 0.
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
I0703 12:38:52.538849 139733218952960 functions.py:432] Going to execute flow 'sklearn.pipeline.Pipeline(imputer=sklearn.preprocessing.imputation.Imputer,estimator=sklearn.tree.tree.DecisionTreeClassifier)' on task 97 for repeat 0 fold 2 sample 0.
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
I0703 12:38:52.588593 139733218952960 functions.py:432] Going to execute flow 'sklearn.pipeline.Pipeline(imputer=sklearn.preprocessing.imputation.Imputer,estimator=sklearn.tree.tree.DecisionTreeClassifier)' on task 97 for repeat 0 fold 3 sample 0.
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
I0703 12:38:52.638321 139733218952960 functions.py:432] Going to execute flow 'sklearn.pipeline.Pipeline(imputer=sklearn.preprocessing.imputation.Imputer,estimator=sklearn.tree.tree.DecisionTreeClassifier)' on task 97 for repeat 0 fold 4 sample 0.
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
I0703 12:38:52.688356 139733218952960 functions.py:432] Going to execute flow 'sklearn.pipeline.Pipeline(imputer=sklearn.preprocessing.imputation.Imputer,estimator=sklearn.tree.tree.DecisionTreeClassifier)' on task 97 for repeat 0 fold 5 sample 0.
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
I0703 12:38:52.738678 139733218952960 functions.py:432] Going to execute flow 'sklearn.pipeline.Pipeline(imputer=sklearn.preprocessing.imputation.Imputer,estimator=sklearn.tree.tree.DecisionTreeClassifier)' on task 97 for repeat 0 fold 6 sample 0.
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
I0703 12:38:52.788713 139733218952960 functions.py:432] Going to execute flow 'sklearn.pipeline.Pipeline(imputer=sklearn.preprocessing.imputation.Imputer,estimator=sklearn.tree.tree.DecisionTreeClassifier)' on task 97 for repeat 0 fold 7 sample 0.
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
I0703 12:38:52.839610 139733218952960 functions.py:432] Going to execute flow 'sklearn.pipeline.Pipeline(imputer=sklearn.preprocessing.imputation.Imputer,estimator=sklearn.tree.tree.DecisionTreeClassifier)' on task 97 for repeat 0 fold 8 sample 0.
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
I0703 12:38:52.889438 139733218952960 functions.py:432] Going to execute flow 'sklearn.pipeline.Pipeline(imputer=sklearn.preprocessing.imputation.Imputer,estimator=sklearn.tree.tree.DecisionTreeClassifier)' on task 97 for repeat 0 fold 9 sample 0.
/home/travis/miniconda/envs/testenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:58: DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
warnings.warn(msg, category=DeprecationWarning)
I0703 12:38:52.898526 139733218952960 functions.py:255] Executed Task 97 with Flow id:198
URL for run: https://test.openml.org/api/v1/xml/run/38654
openml.config.stop_using_configuration_for_example()
Total running time of the script: ( 0 minutes 5.742 seconds)