Beginner‘s Guide to AutoML with an Easy AutoGluon Example
Machine learning has become an indispensable tool for data scientists, software developers, and domain experts across industries. From healthcare to finance to e-commerce, the ability to automatically learn patterns from data and make predictions enables countless applications. However, the traditional machine learning workflow involves many time-consuming and technically complex steps:
- Data collection and cleaning
- Exploratory data analysis
- Feature engineering and selection
- Model training and hyperparameter tuning
- Model evaluation and comparison
- Productionization and deployment
Especially for those new to machine learning, it can take substantial time and effort to gain the expertise needed to produce high-quality models. Even for experienced practitioners, the trial-and-error process of feature engineering, algorithm selection, and hyperparameter optimization is often tedious. Automated Machine Learning, or AutoML for short, aims to greatly simplify this workflow and make machine learning more accessible and efficient.
What is AutoML?
AutoML refers to techniques and tools to automate key steps of the machine learning process. The goal is to enable both non-experts and experienced data scientists to quickly build machine learning models without the need for as much manual effort and specialized knowledge.
While definitions vary, a typical AutoML system will automate some or all of the following:
- Data pre-processing: Cleaning, normalization, encoding, imputation of missing values
- Feature engineering: Transforming raw features, feature selection, dimensionality reduction
- Model selection: Choosing the best model/algorithm for the dataset and prediction task
- Hyperparameter optimization: Tuning model parameters to maximize performance
- Results exploration: Generating visualizations and interpretations of models
The user provides the training data and specifies the prediction target, while the AutoML system handles the rest – testing many combinations of features, models, and hyperparameters to produce an optimized result. Some advanced AutoML tools also support neural architecture search and handle deployment of the final model.
Benefits and Use Cases
The key benefits of AutoML include:
-
Improved efficiency – AutoML can test orders of magnitude more models than manual tuning in the same time, leading to better performance with less time and effort. Data scientists can be freed up to focus on higher-level problems.
-
Accessibility – AutoML significantly lowers the barrier to machine learning by automating challenging steps like feature engineering and model selection. Both non-experts and experienced practitioners can leverage AutoML to quickly prototype solutions.
-
Scalability – Modern AutoML systems can train and optimize models over distributed clusters, enabling applications on massive datasets.
-
Reduced risk of human error – Manual feature engineering and model tuning are prone to errors and reproducibility issues. AutoML provides a more rigorous, repeatable workflow.
AutoML has proven effective across a wide range of tabular/structured data problems like customer churn prediction, fraud detection, inventory forecasting, and lead scoring. It has also been applied to text and image data for use cases like sentiment analysis, content moderation, facial recognition and medical imaging diagnostics.
Popular AutoML Frameworks
Many open-source and commercial AutoML tools have emerged in recent years. As of 2023, some popular open-source options include:
- AutoGluon: Developed by AWS, supports tabular, text, image, and multimodal data
- H2O AutoML: Automates training of models from the popular H2O machine learning platform
- MLJAR: AutoML for scikit-learn, LightGBM, XGBoost, CatBoost and more
- FLAML: Fast and lightweight AutoML from Microsoft Research
- auto-sklearn: Automated sklearn pipeline construction
- AutoKeras: AutoML for deep learning models in Keras
On the commercial side, offerings include:
In the rest of this post, we‘ll walk through an example of using the AutoGluon framework to automatically train a high-quality machine learning model on tabular data.
AutoML Example with AutoGluon
AutoGluon is an open-source AutoML framework that enables easy-to-use and high-performance machine learning on image, text, and tabular data. It automates key machine learning steps like data preprocessing, model/hyperparameter selection, and deployment.
First, make sure you have AutoGluon installed (requires Python 3.7+):
pip install autogluon
For this example, we‘ll use the Porto Seguro Safe Driver Prediction dataset from Kaggle, which contains 59 features about driving behavior and vehicle information. The task is to predict the probability that a driver will file an auto insurance claim in the next year.
Let‘s load the data and split it into train and test sets:
from autogluon.tabular import TabularDataset, TabularPredictor
import pandas as pd
from sklearn.model_selection import train_test_split
train_data = TabularDataset(‘train.csv‘)
test_data = TabularDataset(‘test.csv‘)
train_data = train_data.sample(n=20000, random_state=0)
train, val = train_test_split(train_data, test_size=0.2, random_state=0)
With the data ready, we can define an AutoGluon TabularPredictor and call fit() to automatically train an ensemble of models:
predictor = TabularPredictor(label=‘target‘, problem_type=‘binary‘).fit(train_data=train,
tuning_data=val,
time_limit=3600,
presets=‘best_quality‘)
Here we specify:
- The
labelto predict is thetargetcolumn - It‘s a
binaryclassification problem - Use a
time_limitof 1 hour (3600 seconds) - Use
presetsmode of optimizing forbest_quality(slower but most accurate)
Behind the scenes, AutoGluon will automatically:
- Infer the feature types and problem type based on the data
- Preprocess and encode the features
- Train and tune many models from scikit-learn, LightGBM, CatBoost, XGBoost, and neural networks
- Construct a stacked ensemble of the best models
- Tune hyperparameters using the validation (
tuning_data) set
After training completes, we can easily evaluate on our test set and generate predictions:
predictor.evaluate(test_data)
predictor.predict_proba(test_data.drop(columns=[‘target‘]))
This produces the following classification metrics:
accuracy 0.956432 roc_auc 0.655771 f1 0.222493 precision 0.645669 recall 0.134015
Not bad for one line of code! We can also get a leaderboard of the best trained models:
predictor.leaderboard(test_data)

And feature importance scores:
predictor.feature_importance(test_data)

We see that AutoGluon trained nearly 100 different models in the 1 hour time limit, with a weighted ensemble (WeightedEnsemble_L2) and a CatBoost model performing best. The most predictive features relate to the driver‘s age, past claims, and vehicle information.
The trained predictor object can then be saved and deployed for inference on new data:
predictor.save(‘driver_claim_predictor‘)
loaded_predictor = TabularPredictor.load(‘driver_claim_predictor‘)
loaded_predictor.predict(new_data)
In addition to tabular data, AutoGluon also supports automating deep learning for text, image, and even multi-modal data. For example, to train an image classifier:
from autogluon.vision import ImagePredictor
predictor = ImagePredictor()
predictor.fit(train_data=‘image_train‘, hyperparameters={‘epochs‘: 10})
predictions = predictor.predict(test_data=‘image_test‘)
Under the hood, AutoGluon will load a pre-trained image model, fine-tune it on your dataset, and handle all the details of data augmentation, learning rate schedules, early stopping, etc.
Limitations and When Not to Use AutoML
While AutoML is a powerful tool for quickly building ML models, it‘s not a silver bullet. Some limitations to keep in mind:
-
Computationally expensive – AutoML often requires training hundreds of models which can be costly for large datasets. It‘s best suited for small-to-medium sized structured datasets.
-
Black box – The automated nature of AutoML makes it harder to interpret and debug. Models still need to be evaluated carefully for fairness, stability, and other production readiness factors.
-
Can‘t fully replace human expertise – AutoML is not a substitute for domain expertise, feature engineering know-how, and ML fundamentals. Human intuition is still key for creative feature design and problem formulation.
In general, AutoML is most useful when you have a well-defined supervised learning task on a clean tabular dataset and want to quickly generate a baseline model to iterate from. For highly unstructured data, unsupervised/self-supervised learning, or applications requiring a high degree of interpretability and control, standard ML approaches may be preferable.
The Future of AutoML
Looking ahead, we can expect AutoML to only grow in popularity and capability. As the number of ML use cases expands across industries and more non-experts seek to apply ML, the demand for tools to automate and simplify model building will increase.
Trends to watch include:
- Improved support for unstructured data types like audio, video, and multi-modal data
- Integration of AutoML with other aspects of the ML workflow like experiment tracking, model monitoring, and explainable AI
- Automating other stages like problem formulation, weak supervision, and active learning
- Advances in neural architecture search and hyperparameter optimization to build higher-performance models faster
- Serverless/SaaS deployment of AutoML to lower costs and increase accessibility
While there will always be a need for human intuition and expertise, AutoML promises to greatly accelerate the pace of machine learning adoption and application. It‘s an exciting space to watch and get involved with!
Conclusion
AutoML frameworks like AutoGluon are ushering in a new era of accessible and efficient machine learning. By automating key steps like feature engineering, model selection, and hyperparameter tuning, AutoML enables both beginners and experts to quickly build high-quality models with minimal code.
As we‘ve seen in this post, a single line of fit() can automatically train, tune, and ensemble hundreds of models, allowing you to rapidly prototype ML solutions. However, it‘s important to keep in mind the limitations of AutoML and know when to fall back to traditional approaches.
Whether you‘re just getting started with ML or looking to accelerate your workflow, AutoML is a key trend to stay on top of. The future is bright for AutoML and it‘s an exciting time to dive in and experiment with these powerful tools. Happy auto-modeling!