auto-sklearn Documentation
repository·development·Indexed 27 days ago
https://github.com/automl/auto-sklearnAn automated machine learning (AutoML) toolkit that serves as a drop-in replacement for scikit-learn estimators. It automates model selection and hyperparameter optimization for binary, multiclass, and multilabel classification, as well as regression and multioutput regression. The toolkit includes AutoSklearnClassifier and AutoSklearnRegressor, supports various data formats (NumPy, Pandas, SciPy), and provides extension interfaces for custom algorithms and preprocessing steps.
What's inside auto-sklearn
- auto-sklearn is an automated machine learning (AutoML) toolkit designed as a drop-in replacement for scikit-learn estimators. It automates the process of selecting and optimizing machine learning models and hyperparameters.
Supported machine learning tasks in auto-sklearn
developmentauto-sklearn supports the following machine learning tasks:
- Binary Classification
- Multiclass Classification
- Multilabel Classification
- Regression
- Multioutput Regression
You can provide training pairs (
X_train/y_train) to fit an ensemble of pipelines. Optionally, you can provide a testing pair (X_test/y_test) to measure generalization.Quickstart with AutoSklearnClassifier
developmentauto-sklearn is an automated machine learning toolkit designed as a drop-in replacement for scikit-learn estimators. It automates algorithm selection and hyperparameter tuning using Bayesian optimization, meta-learning, and ensemble construction. You can use
AutoSklearnClassifierto fit a model to your training data and then predict on test data using a standard scikit-learn API.import autosklearn.classification cls = autosklearn.classification.AutoSklearnClassifier() cls.fit(X_train, y_train) predictions = cls.predict(X_test)Create aslib files for metadata updates
developmentThe final step in the metadata update process is to create aslib files using
04_create_aslib_files.py.python3 04_create_aslib_files.py --working-directory $working_directory --task-type $task_typeConfigure resource limits (time and memory)
developmentWhen initializing an
auto-sklearnestimator, you must set memory and time limits.Guidelines:
- Memory: For most modern datasets, a limit of 3GB or 6GB is typically sufficient.
- Time: A good default is a total time limit of one day, with a single run limit of 30 minutes.
Note that
auto-sklearnexecutes each machine learning algorithm in its own process to enforce these limits.Implement required methods for custom components
developmentEvery custom component must implement
get_hyperparameter_search_space()andget_properties(). Depending on the component type, you must also implement specific execution methods following the scikit-learn predictor API:- Classification/Regression: Implement
fit()andpredict(). - Feature Preprocessing: Implement
fit()andtransform().
- Classification/Regression: Implement
Generate configuration commands for metadata updates
developmentUse
01_create_commands.pyto generate a file containing all necessary commands to runauto-sklearnon a large number of datasets from OpenML.To customize the process:
- Change task IDs or dataset loading methods in
update_metadata_util.py. - Alter the generated commands file on disk to change the time allocated for configuration.
python3 01_create_commands.py --working-directory $working_directory --task-type $task_type- Change task IDs or dataset loading methods in
Extend auto-sklearn with new components
developmentYou can extendauto-sklearnby implementing new classification, regression, or feature preprocessing methods. To do this, you must create a wrapper class that subclasses the appropriate base class and then register it using the provided registration functions.Reproduce results from the Feurer et al. NIPS paper
developmentThis directory provides scripts to reproduce the results shown in Figure 3 of the paper 'Efficient and Robust Automated Machine Learning' (Feurer et al.).
Note: These scripts are specifically designed for classification tasks and use balanced accuracy as the scoring metric. They can be modified to use different datasets or runtimes.
Execute experiment commands
developmentTo run the experiments defined in
commands.txt, navigate to therundirectory and execute the runner script.Each command in
commands.txtperforms two steps:- Model fitting
- Creating single best and ensemble trajectories.
Parallelization: You can run these commands in parallel on a cluster by modifying
run_commands.shto distribute the tasks.cd run bash run_commands.shInstall auto-sklearn via Anaconda/Conda
developmentTo install
auto-sklearnvia Anaconda, you must first enable theconda-forgechannel. Ensure you haveconda >= 4.9installed.1. Enable conda-forge
conda config --add channels conda-forge conda config --set channel_priority strict2. Install auto-sklearn
conda install auto-sklearn3. Troubleshooting Compiler Incompatibility
On some recent Linux distributions, the compiler used by Anaconda may conflict with the system compiler. You can resolve this by installing the Anaconda-provided GCC and SWIG:
conda install gxx_linux-64 gcc_linux-64 swigTo see available versions on your platform:
conda search auto-sklearn --channel conda-forgeconda config --add channels conda-forge conda config --set channel_priority strict conda install auto-sklearnInstall OpenML package for metadata updates
developmentMetadata updates require the OpenML python package and an OpenML account. Refer to the OpenML python package manual for installation instructions.