Provide an input CSV and a target field to predict, generate a model + code to run it.

Overview

automl-gs

console gif

Give an input CSV file and a target field you want to predict to automl-gs, and get a trained high-performing machine learning or deep learning model plus native Python code pipelines allowing you to integrate that model into any prediction workflow. No black box: you can see exactly how the data is processed, how the model is constructed, and you can make tweaks as necessary.

demo output

automl-gs is an AutoML tool which, unlike Microsoft's NNI, Uber's Ludwig, and TPOT, offers a zero code/model definition interface to getting an optimized model and data transformation pipeline in multiple popular ML/DL frameworks, with minimal Python dependencies (pandas + scikit-learn + your framework of choice). automl-gs is designed for citizen data scientists and engineers without a deep statistical background under the philosophy that you don't need to know any modern data preprocessing and machine learning engineering techniques to create a powerful prediction workflow.

Nowadays, the cost of computing many different models and hyperparameters is much lower than the opportunity cost of an data scientist's time. automl-gs is a Python 3 module designed to abstract away the common approaches to transforming tabular data, architecting machine learning/deep learning models, and performing random hyperparameter searches to identify the best-performing model. This allows data scientists and researchers to better utilize their time on model performance optimization.

  • Generates native Python code; no platform lock-in, and no need to use automl-gs after the model script is created.
  • Train model configurations super-fast for free using a TPU and TensorFlow in Google Colaboratory. (in Beta: you can access the Colaboratory notebook here).
  • Handles messy datasets that normally require manual intervention, such as datetime/categorical encoding and spaced/parenthesized column names.
  • Each part of the generated model pipeline is its own function w/ docstrings, making it much easier to integrate into production workflows.
  • Extremely detailed metrics reporting for every trial stored in a tidy CSV, allowing you to identify and visualize model strengths and weaknesses.
  • Correct serialization of data pipeline encoders on disk (i.e. no pickled Python objects!)
  • Retrain the generated model on new data without making any code/pipeline changes.
  • Quit the hyperparameter search at any time, as the results are saved after each trial.
  • Training progress bars with ETAs for both the overall experiment and per-epoch during the experiment.

The models generated by automl-gs are intended to give a very strong baseline for solving a given problem; they're not the end-all-be-all that often accompanies the AutoML hype, but the resulting code is easily tweakable to improve from the baseline.

You can view the hyperparameters and their values here, and the metrics that can be optimized here. Some of the more controversial design decisions for the generated models are noted in DESIGN.md.

Framework Support

Currently automl-gs supports the generation of models for regression and classification problems using the following Python frameworks:

  • TensorFlow (via tf.keras) | tensorflow
  • XGBoost (w/ histogram binning) | xgboost

To be implemented:

  • Catboost | catboost
  • LightGBM | lightgbm

How to Use

automl-gs can be installed via pip:

pip3 install automl_gs

You will also need to install the corresponding ML/DL framework (e.g. tensorflow/tensorflow-gpu for TensorFlow, xgboost for xgboost, etc.)

After that, you can run it directly from the command line. For example, with the famous Titanic dataset:

automl_gs titanic.csv Survived

If you want to use a different framework or configure the training, you can do it with flags:

automl_gs titanic.csv Survived --framework xgboost --num_trials 1000

You may also invoke automl-gs directly from Python. (e.g. via a Jupyter Notebook)

from automl_gs import automl_grid_search

automl_grid_search('titanic.csv', 'Survived')

The output of the automl-gs training is:

  • A timestamped folder (e.g. automl_tensorflow_20190317_020434) with contains:
    • model.py: The generated model file.
    • pipeline.py: The generated pipeline file.
    • requirements.txt: The generated requirements file.
    • /encoders: A folder containing JSON-serialized encoder files
    • /metadata: A folder containing training statistics + other cool stuff not yet implemented!
    • The model itself (format depends on framework)
  • automl_results.csv: A CSV containing the training results after each epoch and the hyperparameters used to train at that time.

Once the training is done, you can run the generated files from the command line within the generated folder above.

To predict:

python3 model.py -d data.csv -m predict

To retrain the model on new data:

python3 model.py -d data.csv -m train

CLI Arguments/Function Parameters

You can view these at any time by running automl_gs -h in the command line.

  • csv_path: Path to the CSV file (must be in the current directory) [Required]
  • target_field: Target field to predict [Required]
  • target_metric: Target metric to optimize [Default: Automatically determined depending on problem type]
  • framework: Machine learning framework to use [Default: 'tensorflow']
  • model_name: Name of the model (if you want to train models with different names) [Default: 'automl']
  • num_trials: Number of trials / different hyperparameter combos to test. [Default: 100]
  • split: Train-validation split when training the models [Default: 0.7]
  • num_epochs: Number of epochs / passes through the data when training the models. [Default: 20]
  • col_types: Dictionary of fields:data types to use to override automl-gs's guesses. (only when using in Python) [Default: {}]
  • gpu: For non-Tensorflow frameworks and Pascal-or-later GPUs, boolean to determine whether to use GPU-optimized training methods (TensorFlow can detect it automatically) [Default: False]
  • tpu_address: For TensorFlow, hardware address of the TPU on the system. [Default: None]

Examples

For a quick Hello World on how to use automl-gs, see this Jupyter Notebook.

Due to the size of some examples w/ generated code and accompanying data visualizations, they are maintained in a separate repository. (and also explain why there are two distinct "levels" in the example viz above!)

How automl-gs Works

TL;DR: auto-ml gs generates raw Python code using Jinja templates and trains a model using the generated code in a subprocess: repeat using different hyperparameters until done and save the best model.

automl-gs loads a given CSV and infers the data type of each column to be fed into the model. Then it tries a ETL strategy for each column field as determined by the hyperparameters; for example, a Datetime field has its hour and dayofweek binary-encoded by default, but hyperparameters may dictate the encoding of month and year as additional model fields. ETL strategies are optimized for frameworks; TensorFlow for example will use text embeddings, while other frameworks will use CountVectorizers to encode text (when training, TensorFlow will also used a shared text encoder via Keras's functional API). automl-gs then creates a statistical model with the specified framework. Both the model ETL functions and model construction functions are saved as a generated Python script.

automl-gs then runs the generated training script as if it was a typical user. Once the model is trained, automl-gs saves the training results in its own CSV, along with all the hyperparameters used to train the model. automl-gs then repeats the task with another set of hyperparameters, until the specified number of trials is hit or the user kills the script.

The best model Python script is kept after each trial, which can then easily be integrated into other scripts, or run directly to get the prediction results on a new dataset.

Helpful Notes

  • It is the user's responsibility to ensure the input dataset is high-quality. No model hyperparameter search will provide good research on flawed/unbalanced datasets. Relatedly, hyperparameter optimization may provide optimistic predictions on the validation set, which may not necessarily match the model performance in the real world.
  • A neural network approach alone may not necessarily be the best approach. Try using xgboost. The results may surprise you!
  • automl-gs is only attempting to solve tabular data problems. If you have a more complicated problem to solve (e.g. predicting a sequence of outputs), I recommend using Microsoft's NNI and Uber's Ludwig as noted in the introduction.

Known Issues

  • Issues when using Anaconda (#8). Use an installed Python is possible.
  • Issues when using Windows (#13)
  • Issues when a field name in the input dataset starts with a number (#18)

Future Work

Feature development will continue on automl-gs as long as there is interest in the package.

Top Priority

  • Add more frameworks
  • Results visualization (via plotnine)
  • Holiday support for datetimes
  • Remove redundant generated code
  • Native distributed/high level automation support (Polyaxon/Kubernetes, Airflow)
  • Image field support (both as a CSV column field, and a special flow mode to take advantage of hyperparameter tuning)
  • PyTorch model code generation.

Elsework

  • Generate script given an explicit set of hyperparameters
  • More hyperparameters.
  • Bayesian hyperparameter search for standalone version.
  • Support for generating model code for R/Julia
  • Tool for generating a Flask/Starlette REST API from a trained model script
  • Allow passing an explicit, pre-defined test set CSV.

Maintainer/Creator

Max Woolf (@minimaxir)

Max's open-source projects are supported by his Patreon. If you found this project helpful, any monetary contributions to the Patreon are appreciated and will be put to good creative use.

License

MIT

The code generated by automl-gs is unlicensed; the owner of the generated code can decide the license.

Comments
  • YAMLLoadWarning disrupting progress bar

    YAMLLoadWarning disrupting progress bar

    Trying out the example titanic dataset in a conda environment and encountered the following error very frequently such that it disrupts the tqdm progress bar.

    /anaconda3/envs/automl-gs/lib/python3.6/site-packages/automl_gs/utils_automl.py:270:
    YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default 
    Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
      metrics = yaml.load(f)
    
    opened by remykarem 3
  • fix #13

    fix #13

    This initial commit enables automl-gs to work on win10. I can test on win8 and linux, but don't have access to a Mac to make sure everything still works normally there.

    opened by evan-burke 3
  •  FileNotFoundError

    FileNotFoundError

    Hi,

    Just trying to work through your example colab notebook. I work through the cells, upload the titanic.csv, and get

    ---------------------------------------------------------------------------
    
    FileNotFoundError                         Traceback (most recent call last)
    
    <ipython-input-3-9f452c025bdd> in <module>()
          2                    target_field='origin',
          3                    model_name='tpu',
    ----> 4                    tpu_address = tpu_address)
    
    5 frames
    
    /usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
       1889         kwds["usecols"] = self.usecols
       1890 
    -> 1891         self._reader = parsers.TextReader(src, **kwds)
       1892         self.unnamed_cols = self._reader.unnamed_cols
       1893 
    
    pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
    
    pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()
    
    FileNotFoundError: [Errno 2] File tpu_train/metadata/results.csv does not exist: 'tpu_train/metadata/results.csv'
    
    
    opened by shawngraham 1
  • xgboost: GPU support

    xgboost: GPU support

    xgboost supports GPUs by setting gpu_hist instead of hist, and the code is prepared for that. Two problems:

    1. Unlike TensorFlow, xgboost does not have a way to automatically determine if a GPU is present.
    2. GPU hist training requires a Pascal minimum; the GPUs in Colaboratory notebooks are K80s (Kepler) which does not qualify.

    Will keep at CPU support for now but there has to be a better solution.

    opened by minimaxir 1
  • Fixed some typos and grammar

    Fixed some typos and grammar

    Changes:

    1. parathesized ==> parenthesized
    2. JSON-seralized ==> JSON-serialized
    3. necessairly ==> necessarily (2)
    4. hyperameter ==> hyperparameter
    opened by mikeshatch 0
  • Ensure col_types works as expected

    Ensure col_types works as expected

    I started playing with a slightly messy file I had available, and noticed that the col_types argument didn't seem to work to allow me to ignore/override some columns. Found what seems to be the issue and it works for me locally.

    Thanks!

    opened by drien 0
  • SyntaxError: invalid decimal literal produced by automl

    SyntaxError: invalid decimal literal produced by automl

    Wanted to try automl_gs, but I get this error and can't figure out why.

    File "C:\Users\XXX\automl_train\model.py", line 3, in from pipeline import * File "C:\Users\XXX\automl_train\pipeline.py", line 29 0_enc = df['0'] ^ SyntaxError: invalid decimal literal

    Any ideas about that?

    opened by Haifischfutter 0
  • Google Colab - automl_train/metadata/results.csv does not exist

    Google Colab - automl_train/metadata/results.csv does not exist

    Input:

    from automl_gs import automl_grid_search
    
    automl_grid_search("data.csv", "diagnosis")
    

    Output:

    Solving a binary_classification problem, maximizing accuracy using tensorflow.
    
    Modeling with field specifications:
    id: ignore
    radius_mean: numeric
    texture_mean: numeric
    perimeter_mean: numeric
    area_mean: numeric
    smoothness_mean: numeric
    compactness_mean: numeric
    concavity_mean: numeric
    concave points_mean: numeric
    symmetry_mean: numeric
    fractal_dimension_mean: numeric
    radius_se: numeric
    texture_se: numeric
    perimeter_se: numeric
    area_se: numeric
    smoothness_se: numeric
    compactness_se: numeric
    concavity_se: numeric
    concave points_se: numeric
    symmetry_se: numeric
    fractal_dimension_se: numeric
    radius_worst: numeric
    texture_worst: numeric
    perimeter_worst: numeric
    area_worst: numeric
    smoothness_worst: numeric
    compactness_worst: numeric
    concavity_worst: numeric
    concave points_worst: numeric
    symmetry_worst: numeric
    fractal_dimension_worst: numeric
    Unnamed: 32: numeric
    0%
    0/100 [00:04<?, ?trial/s]
    0%
    0/20 [00:00<?, ?epoch/s]
    ---------------------------------------------------------------------------
    FileNotFoundError                         Traceback (most recent call last)
    <ipython-input-37-308e97508c91> in <module>()
          1 from automl_gs import automl_grid_search
          2 
    ----> 3 automl_grid_search("data.csv", "diagnosis")
    
    5 frames
    /usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
       1889         kwds["usecols"] = self.usecols
       1890 
    -> 1891         self._reader = parsers.TextReader(src, **kwds)
       1892         self.unnamed_cols = self._reader.unnamed_cols
       1893 
    
    pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
    
    pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()
    
    FileNotFoundError: [Errno 2] File automl_train/metadata/results.csv does not exist: 'automl_train/metadata/results.csv'
    
    opened by batmanscode 3
  • Fix duplicates kwarg in pd.cut

    Fix duplicates kwarg in pd.cut

    From pandas version >= 0.23 you have to specify 'duplicates' kwarg to drop duplicates in 'bins' array. Otherwise, it will throw an error.

    https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.cut.html

    opened by kitkatk 0
  • Using automl-gs for bin packing

    Using automl-gs for bin packing

    Is there any way to use a tool like automl-gs for bin-packing problems? I've seen a way to model it as linear optimization where you do a cross join of all objects and all potential bins, set a constraint of each object being selected once, and then optimizing the bins however desired. Cross joins can end up being needlessly heavy though, so I'm wondering if there is a way to model that sort of problem such that you could use pre-optimized and continually developed tools like this one.

    opened by jdotjdot 0
  • AttributeError: 'float' object has no attribute 'lower'

    AttributeError: 'float' object has no attribute 'lower'

    While trying out automl_gs with Jupiter, I got file not found error:

    FileNotFoundError: [Errno 2] File b'automl_train/metadata/results.csv' does not exist: b'automl_train/metadata/results.csv'

    Trying do it with terminal before the file missing error it returns:

    AttributeError: 'float' object has no attribute 'lower'

    Searching in StackOverflow, I found that the problem is how pandas converts inputs to python datatypes.

    https://stackoverflow.com/questions/34724246/attributeerror-float-object-has-no-attribute-lower/34724771

    Is it possible to prevent this behaviour using automl_gs ?

    opened by AlexandraMakarova 0
Releases(v0.2.1)
Owner
Max Woolf
Data Scientist @buzzfeed. Plotter of pretty charts.
Max Woolf
Breast-Cancer-Classification - Using SKLearn breast cancer dataset which contains 569 examples and 32 features classifying has been made with 6 different algorithms

Breast-Cancer-Classification - Using SKLearn breast cancer dataset which contains 569 examples and 32 features classifying has been made with 6 different algorithms

Mert Sezer Ardal 1 Jan 31, 2022
A benchmark of data-centric tasks from across the machine learning lifecycle.

A benchmark of data-centric tasks from across the machine learning lifecycle.

61 Dec 28, 2022
A statistical library designed to fill the void in Python's time series analysis capabilities, including the equivalent of R's auto.arima function.

pmdarima Pmdarima (originally pyramid-arima, for the anagram of 'py' + 'arima') is a statistical library designed to fill the void in Python's time se

alkaline-ml 1.3k Jan 06, 2023
nn-Meter is a novel and efficient system to accurately predict the inference latency of DNN models on diverse edge devices

A DNN inference latency prediction toolkit for accurately modeling and predicting the latency on diverse edge devices.

Microsoft 241 Dec 26, 2022
A library to generate synthetic time series data by easy-to-use factors and generator

timeseries-generator This repository consists of a python packages that generates synthetic time series dataset in a generic way (under /timeseries_ge

Nike Inc. 87 Dec 20, 2022
fastFM: A Library for Factorization Machines

Citing fastFM The library fastFM is an academic project. The time and resources spent developing fastFM are therefore justified by the number of citat

1k Dec 24, 2022
Implementation of the Object Relation Transformer for Image Captioning

Object Relation Transformer This is a PyTorch implementation of the Object Relation Transformer published in NeurIPS 2019. You can find the paper here

Yahoo 158 Dec 24, 2022
A collection of Scikit-Learn compatible time series transformers and tools.

tsfeast A collection of Scikit-Learn compatible time series transformers and tools. Installation Create a virtual environment and install: From PyPi p

Chris Santiago 0 Mar 30, 2022
cuML - RAPIDS Machine Learning Library

cuML - GPU Machine Learning Algorithms cuML is a suite of libraries that implement machine learning algorithms and mathematical primitives functions t

RAPIDS 3.1k Dec 28, 2022
Class-imbalanced / Long-tailed ensemble learning in Python. Modular, flexible, and extensible

IMBENS: Class-imbalanced Ensemble Learning in Python Language: English | Chinese/中文 Links: Documentation | Gallery | PyPI | Changelog | Source | Downl

Zhining Liu 176 Jan 04, 2023
Lseng-iseng eksplor Machine Learning dengan menggunakan library Scikit-Learn

Kalo dengar istilah ML, biasanya rada ambigu. Soalnya punya beberapa kepanjangan, seperti Mobile Legend, Makan Lontong, Ma**ng L*v* dan lain-lain. Tapi pada repo ini membahas Machine Learning :)

Alfiyanto Kondolele 1 Apr 06, 2022
Python implementation of the rulefit algorithm

RuleFit Implementation of a rule based prediction algorithm based on the rulefit algorithm from Friedman and Popescu (PDF) The algorithm can be used f

Christoph Molnar 326 Jan 02, 2023
A logistic regression model for health insurance purchasing prediction

Logistic_Regression_Model A logistic regression model for health insurance purchasing prediction This code is using these packages, so please make sur

ShawnWang 1 Nov 29, 2021
李航《统计学习方法》复现

本项目复现李航《统计学习方法》每一章节的算法 特点: 笔记摘要:在每个文件开头都会有一些核心的摘要 pythonic:这里会用尽可能规范的方式来实现,包括编程风格几乎严格按照PEP8 循序渐进:前期的算法会更list的方式来做计算,可读性比较强,后期几乎完全为numpy.array的计算,并且辅助详

58 Oct 22, 2021
BentoML is a flexible, high-performance framework for serving, managing, and deploying machine learning models.

Model Serving Made Easy BentoML is a flexible, high-performance framework for serving, managing, and deploying machine learning models. Supports multi

BentoML 4.4k Jan 04, 2023
CobraML: Completely Customizable A python ML library designed to give the end user full control

CobraML: Completely Customizable What is it? CobraML is a python library built on both numpy and numba. Unlike other ML libraries CobraML gives the us

Sriram Govindan 14 Dec 19, 2021
AutoX是一个高效的自动化机器学习工具,它主要针对于表格类型的数据挖掘竞赛。 它的特点包括: 效果出色、简单易用、通用、自动化、灵活。

English | 简体中文 AutoX是什么? AutoX一个高效的自动化机器学习工具,它主要针对于表格类型的数据挖掘竞赛。 它的特点包括: 效果出色: AutoX在多个kaggle数据集上,效果显著优于其他解决方案(见效果对比)。 简单易用: AutoX的接口和sklearn类似,方便上手使用。

4Paradigm 431 Dec 28, 2022
Conducted ANOVA and Logistic regression analysis using matplot library to visualize the result.

Intro-to-Data-Science Conducted ANOVA and Logistic regression analysis. Project ANOVA The main aim of this project is to perform One-Way ANOVA analysi

Chris Yuan 1 Feb 06, 2022
Mixing up the Invariant Information clustering architecture, with self supervised concepts from SimCLR and MoCo approaches

Self Supervised clusterer Combined IIC, and Moco architectures, with some SimCLR notions, to get state of the art unsupervised clustering while retain

Bendidi Ihab 9 Feb 13, 2022
A Python library for choreographing your machine learning research.

A Python library for choreographing your machine learning research.

AI2 270 Jan 06, 2023