.. 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 Fitting to the training data: 0%| | 0/120 [00:00` .. 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 `_