.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/60_search/example_parallel_n_jobs.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_60_search_example_parallel_n_jobs.py: =================================== Parallel Usage on a single machine =================================== *Auto-sklearn* uses `dask.distributed _ for parallel optimization. This example shows how to start *Auto-sklearn* to use multiple cores on a single machine. Using this mode, *Auto-sklearn* starts a dask cluster, manages the workers and takes care of shutting down the cluster once the computation is done. To run *Auto-sklearn* on multiple machines check the example :ref:`sphx_glr_examples_60_search_example_parallel_manual_spawning_cli.py`. .. GENERATED FROM PYTHON SOURCE LINES 18-26 .. code-block:: default import sklearn.model_selection import sklearn.datasets import sklearn.metrics import autosklearn.classification .. GENERATED FROM PYTHON SOURCE LINES 27-29 Data Loading ============ .. GENERATED FROM PYTHON SOURCE LINES 29-34 .. code-block:: default 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 ) .. GENERATED FROM PYTHON SOURCE LINES 35-39 Build and fit a classifier ========================== To use ``n_jobs_`` we must guard the code .. GENERATED FROM PYTHON SOURCE LINES 39-55 .. code-block:: default if __name__ == "__main__": automl = autosklearn.classification.AutoSklearnClassifier( time_left_for_this_task=120, per_run_time_limit=30, tmp_folder="/tmp/autosklearn_parallel_1_example_tmp", n_jobs=4, # Each one of the 4 jobs is allocated 3GB memory_limit=3072, seed=5, ) automl.fit(X_train, y_train, dataset_name="breast_cancer") # Print statistics about the auto-sklearn run such as number of # iterations, number of models failed with a time out. print(automl.sprint_statistics()) .. rst-class:: sphx-glr-script-out .. code-block:: none auto-sklearn results: Dataset name: breast_cancer Metric: accuracy Best validation score: 0.985816 Number of target algorithm runs: 43 Number of successful target algorithm runs: 43 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 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 2 minutes 1.338 seconds) .. _sphx_glr_download_examples_60_search_example_parallel_n_jobs.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/60_search/example_parallel_n_jobs.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_parallel_n_jobs.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_parallel_n_jobs.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_