Skip to main content

A Python package for fast exploration and experimentation of supervised machine learning pipelines.

Project description

ATOM

Automated Tool for Optimized Modelling

Author: tvdboom      Email: m.524687@gmail.com      Documentation: https://tvdboom.github.io/ATOM/

Repository:

Project Status: Active Conda Recipe Python 3.6|3.7|3.8|3.9 License: MIT Conda Platforms

Release info:

PyPI version Conda Version Downloads

Build status:

Build Status Azure Pipelines codecov

Code analysis:

Code style: black Language grade: Python Total alerts



Description

There is no magic formula in data science that can tell us which type of machine learning algorithm will perform best for a specific use-case. Different models are better suited for different types of data and different problems. At best, you can follow some rough guide on how to approach problems with regard to which model to try on your data, but these are often more confusing than helpful. Best practices tell us to start with a simple model (e.g. linear regression) and build up to more complicated models (e.g. linear regression -> random forest -> multi-layer perceptron) if you are not satisfied with the results. Unfortunately, different models require different data cleaning steps, different type/amount of features, tuning a new set of hyperparameters, etc. Refactoring the code for this purpose can be quite boring and time-consuming. Because of this, many data scientists end up just using the model best known to them and fine-tuning this particular model without ever trying different ones. This can result in poor performance (because the model is just not the right one for the task) or in poor time management (because you could have achieved a similar performance with a simpler/faster model).

ATOM is made to help you solve these issues. With just a few lines of code, you can perform basic data cleaning steps, select relevant features and compare the performance of multiple models on a given dataset. ATOM should be able to provide quick insights on which algorithms perform best for the task at hand and provide an indication of the feasibility of the ML solution.

It is important to realize that ATOM is not here to replace all the work a data scientist has to do before getting his model into production. ATOM doesn't spit out production-ready models just by tuning some parameters in its API. After helping you to determine the right model, you will most probably need to fine-tune it using use-case specific features and data cleaning steps in order to achieve maximum performance.

So, this sounds a bit like AutoML, how is ATOM different than auto-sklearn or TPOT? Well, ATOM does AutoML in the sense that it helps you find the best model for a specific task, but contrary to the aforementioned packages, it does not actively search for the best model. It simply runs all of them and let you pick the one that you think suites the task best. AutoML packages are often black boxes: if you provide data, it will magically return a working model. Although it works great, they often produce complicated pipelines with low explainability. This is hard to sell to the business. In this, ATOM excels. Every step of the pipeline is accounted for, and using the provided plotting methods, it’s easy to demonstrate why a model is a better or worse choice than the other.

Example steps taken by ATOM's pipeline:

  1. Data Cleaning
    • Handle missing values
    • Encode categorical features
    • Remove outliers
    • Balance the dataset
  2. Feature engineering
    • Create new non-linear features
    • Remove multi-collinear features
    • Remove features with too low variance
    • Select the most promising features based on a statistical test
  3. Train and validate multiple models
    • Select hyperparameters using a Bayesian Optimization approach
    • Train and test the models on the provided data
    • Perform bagging to assess the robustness of the output
  4. Analyze the results
    • Get the model scores on various metrics
    • Make plots to compare the model performances



diagram



Installation

NOTE: Since atom was already taken, download the package under the name atom-ml!

Install ATOM's newest release easily via pip:

$ pip install -U atom-ml

or via conda:

$ conda install -c conda-forge atom-ml



Usage

Call the ATOMClassifier or ATOMRegressor class and provide the data you want to use:

from sklearn.datasets import load_breast_cancer
from atom import ATOMClassifier

X, y = load_breast_cancer(return_X_y)
atom = ATOMClassifier(X, y, logger="auto", n_jobs=2, verbose=2)

ATOM has multiple data cleaning methods to help you prepare the data for modelling:

atom.impute(strat_num="knn", strat_cat="most_frequent",  min_frac_rows=0.1)  
atom.encode(strategy="Target", max_onehot=8, frac_to_other=0.05)  
atom.feature_selection(strategy="PCA", n_features=12)

Run the pipeline with the models you want to compare:

atom.run(
    models=["LR", "LDA", "XGB", "lSVM"],
    metric="f1",
    n_calls=25,
    n_initial_points=10,
    bagging=4
)

Make plots to analyze the results:

atom.plot_results(figsize=(9, 6), filename="bagging_results.png")  
atom.LDA.plot_confusion_matrix(normalize=True, filename="cm.png")



Release history

Version 4.3.0

  • Possibility to add custom transformers to the pipeline.
  • The export_pipeline utility method exports atom's current pipeline to a sklearn object.
  • Use AutoML to automate the search for an optimized pipeline.
  • New magic methods makes atom behave similarly to sklearn's Pipeline.
  • All training approaches can now be combined in the same atom instance.
  • New plot_scatter_matrix, plot_distribution and plot_qq for data inspection.
  • Complete rework of all the shap plots to be consistent with their new API.
  • Improvements for the Scaler and Pruner classes.
  • The acronym for custom models now defaults to the capital letters in the class' __name__.
  • Possibility to apply transformations on only a subset of the columns.
  • Plots and methods now accept winner as model name.
  • Fixed a bug where custom metrics didn't show the correct name.
  • Fixed a bug where timers were not displayed correctly.
  • Further compatibility with deep learning datasets.
  • Large refactoring for performance optimization.
  • Cleaner output of messages to the logger.
  • Plots no longer show a default title.
  • Added the AutoML example notebook.
  • Minor bug fixes.

Version 4.2.1

  • Bug fix where there was memory leakage in successive halving and train sizing pipelines.
  • The XGBoost, LightGBM and CatBoost packages can now be installed through the installer's extras_require under the name models, e.g. pip install -U atom-ml[models].
  • Improved documentation.

Version 4.2.0

  • Possibility to add custom models to the pipeline using ATOMModel.
  • Compatibility with deep learning models.
  • New branch system for different data pipelines. Read more in the user guide.
  • Use the canvas contextmanager to draw multiple plots in one figure.
  • New voting and stacking ensemble techniques.
  • New get_class_weight utility method.
  • Added the sample_weight parameter to the score method.
  • New Sequential Feature Selection strategy for the FeatureSelector.
  • New ways to initialize the data in the trainers.
  • The n_rows parameter in ATOMLoader is deprecated in favour of the new data input formats.
  • The test_size parameter now also allows integer values.
  • Renamed categories to classes to be consistent with sklearn's API.
  • The class property now returns a pd.DataFrame of the number of rows per target class in the train, test and complete dataset.
  • Possibility to add custom parameters to an estimator's fit method through est_params.
  • Successive halving and train sizing now both allow subsequent runs from atom without losing previous information.
  • Bug fix where ATOMLoader wouldn't encode the target column during transformation.
  • Added the Deep learning, Ensembles and Utilities example notebooks.
  • Compatibility with python 3.9.

Version 4.1.0

  • Added the est_params parameter to customize the parameters passed to every model's estimator.
  • Following skopt's API, the n_random_starts parameter is deprecated in favour of n_initial_points.
  • The Balancer class now allows you to use any of the strategies from imblearn.
  • New utility attributes to inspect the dataset.
  • Four new models: CatNB, CNB, ARD and RNN.
  • Added the models section to the documentation.
  • Small changes in log outputs.
  • Bug fixes and performance improvements.

Version 4.0.1

  • Bug fix where the DFS strategy in FeatureGenerator was not deterministic for a fixed random state.
  • Bug fix where subsequent runs with the same metric failed.
  • Added the license file to the package's installer.
  • Typo fixes in documentation.

Version 4.0.0

  • Bayesian optimization package changed from GpyOpt to skopt.
  • Complete revision of the model's hyperparameters.
  • Four SHAP plots can now be called directly from an ATOM pipeline.
  • Two new plots for regression tasks.
  • New plot_pipeline and pipeline attribute to access all transformers.
  • Possibility to determine transformer parameters per method.
  • New calibration method and plot.
  • Metrics can now be added as scorers or functions with signature metric(y, y_pred, **kwargs).
  • Implementation of multi-metric runs.
  • Possibility to choose which metric to plot.
  • Early stopping for models that allow in-training evaluation.
  • Added the ATOMLoader function to load saved atom instances and directly apply all data transformations.
  • The "remove" strategy in the data cleaning parameters is deprecated in favour of "drop".
  • Implemented the DFS strategy in FeatureGenerator.
  • All training classes now inherit from BaseEstimator.
  • Added multiple new example notebooks.
  • Tests coverage up to 100%.
  • Completely new documentation page.
  • Bug fixes and performance improvements.



Documentation

For further information about ATOM, please see the project's documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atom-ml-4.3.0.tar.gz (1.0 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page