Study interactive :: Progress tools open in the Study Hub reader.

AutoML Basics Guide

Comprehensive introduction to Automated Machine Learning (AutoML): when to use it, popular tools, and integration with manual ML workflows.

Table of Contents


Introduction to AutoML

What is AutoML?

Automated Machine Learning (AutoML) automates the end-to-end process of applying machine learning to real-world problems. It automates:

Goal: Make ML accessible to non-experts and accelerate ML development for experts.

Why AutoML Exists

Challenges in Manual ML:

AutoML Solution:


What AutoML Does

1. Algorithm Selection

Automatically tries multiple algorithms and selects the best one:

2. Hyperparameter Tuning

Automatically searches for optimal hyperparameters:

3. Feature Engineering

Automatically creates and selects features:

4. Model Selection

Compares multiple models and selects the best:

5. Pipeline Creation

Builds complete ML pipelines:


When to Use AutoML

Good Use Cases

1. Rapid Prototyping

2. Limited ML Expertise

3. Standard Problems

4. Baseline Establishment

5. Feature Exploration

When NOT to Use AutoML

1. Highly Custom Problems

2. Interpretability Critical

3. Limited Compute Resources

4. Research/Innovation

5. Very Large Datasets


1. H2O AutoML

Best for: Production ML, enterprise use

import h2o
from h2o.automl import H2OAutoML

# Initialize H2O
h2o.init()

# Load data
df = h2o.import_file("data.csv")

# Define features and target
x = df.columns[:-1]  # All columns except last
y = df.columns[-1]   # Last column is target

# Run AutoML
aml = H2OAutoML(max_models=20, seed=42, max_runtime_secs=3600)
aml.train(x=x, y=y, training_frame=df)

# View leaderboard
print(aml.leaderboard)

# Get best model
best_model = aml.leader

# Make predictions
predicti>

Pros:

Cons:

2. TPOT (Tree-based Pipeline Optimization Tool)

Best for: Research, feature engineering exploration

from tpot import TPOTClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

# Load data
iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(
    iris.data, iris.target, test_size=0.2, random_state=42
)

# Create TPOT classifier
tpot = TPOTClassifier(
    generations=5,           # Number of iterations
    population_size=20,      # Population size
    random_state=42,
    verbosity=2,
    max_time_mins=10        # Maximum time in minutes
)

# Fit TPOT
tpot.fit(X_train, y_train)

# Evaluate
print(f"Accuracy: {tpot.score(X_test, y_test):.3f}")

# Export best pipeline code
tpot.export('tpot_pipeline.py')

Pros:

Cons:

3. Auto-sklearn

Best for: Quick prototyping, scikit-learn users

import autosklearn.classification
import sklearn.model_selection
import sklearn.datasets
import sklearn.metrics

# Load data
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=42
)

# Create AutoML classifier
automl = autosklearn.classification.AutoSklearnClassifier(
    time_left_for_this_task=120,  # 2 minutes
    per_run_time_limit=30,
    memory_limit=3072,  # 3GB
    random_state=42
)

# Fit
automl.fit(X_train, y_train)

# Predict
y_pred = automl.predict(X_test)

# Evaluate
print(f"Accuracy: {sklearn.metrics.accuracy_score(y_test, y_pred):.3f}")

# Show models
print(automl.show_models())

Pros:

Cons:

4. Google Cloud AutoML

Best for: Cloud users, non-technical users, specific domains

Features:

Pros:

Cons:

5. AutoGluon (Amazon)

Best for: Quick prototyping, tabular data

from autogluon.tabular import TabularPredictor
import pandas as pd

# Load data
train_data = pd.read_csv('train.csv')
test_data = pd.read_csv('test.csv')

# Create predictor
predictor = TabularPredictor(label='target_column').fit(
    train_data,
    time_limit=3600,  # 1 hour
    presets='best_quality'  # or 'medium_quality_faster_inference'
)

# Make predictions
predicti>

# Evaluate
performance = predictor.evaluate(test_data)
print(f"Performance: {performance}")

Pros:

Cons:


AutoML vs Manual ML

Comparison

Aspect AutoML Manual ML
Speed Hours to days Weeks to months
Expertise Required Low to medium High
Control Limited Full control
Interpretability Often lower Can be high
Customization Limited Unlimited
Best Performance Often very good Can be better with expertise
Cost Can be expensive Time-intensive

Best Practice: Use AutoML for baseline, then manually optimize

# Step 1: AutoML for baseline
from autogluon.tabular import TabularPredictor
predictor = TabularPredictor(label='target').fit(train_data, time_limit=3600)
baseline_score = predictor.evaluate(test_data)

# Step 2: Manual optimization based on insights
# - Review AutoML's feature importance
# - Understand which algorithms worked best
# - Manually tune promising models
# - Add domain-specific features

# Step 3: Compare and choose
final_score = manual_model.evaluate(test_data)
if final_score > baseline_score:
    use_manual_model()
else:
    use_automl_model()

Integration Strategies

Strategy 1: AutoML as Baseline

# 1. Run AutoML to get baseline
automl_model = run_automl(train_data)

# 2. Analyze what worked
feature_importance = automl_model.feature_importances()
best_algorithms = automl_model.get_best_models()

# 3. Build manual model based on insights
manual_model = build_manual_model(
    algorithms=best_algorithms,
    important_features=feature_importance
)

# 4. Compare and ensemble
final_model = ensemble([automl_model, manual_model])

Strategy 2: AutoML for Feature Engineering

# 1. Use AutoML to discover features
automl_features = automl_discover_features(data)

# 2. Extract useful features
useful_features = extract_features(automl_features)

# 3. Build manual model with discovered features
manual_model = build_model(data[useful_features])

Strategy 3: AutoML for Hyperparameter Ranges

# 1. AutoML finds good hyperparameter ranges
automl_results = run_automl(data)

# 2. Extract hyperparameter ranges
param_ranges = extract_param_ranges(automl_results)

# 3. Manual search within those ranges
best_params = manual_search(param_ranges)

Best Practices

1. Set Appropriate Time Limits

# Too short: May not find good models
automl = AutoML(time_limit=60)  # 1 minute - too short

# Too long: Diminishing returns
automl = AutoML(time_limit=86400)  # 24 hours - may be excessive

# Good: Balance between time and quality
automl = AutoML(time_limit=3600)  # 1 hour - reasonable

2. Use Cross-Validation

# AutoML should use cross-validation internally
# But verify it's doing so
automl = AutoML(
    cv_folds=5,  # Ensure cross-validation
    eval_metric='accuracy'
)

3. Monitor Resource Usage

# Set memory limits
automl = AutoML(
    memory_limit=4096,  # 4GB
    time_limit=3600
)

# Monitor during training
import psutil
print(f"Memory usage: {psutil.virtual_memory().percent}%")

4. Interpret Results

# Don't just use best model blindly
# Understand what AutoML found

# Get leaderboard
leaderboard = automl.leaderboard()
print(leaderboard)

# Get feature importance
importance = automl.feature_importance()
print(importance)

# Understand model
best_model = automl.leader
print(best_model.summary())

5. Validate on Holdout Set

# Always keep a holdout test set
X_train, X_temp, y_train, y_temp = train_test_split(X, y, test_size=0.4)
X_val, X_test, y_val, y_test = train_test_split(X_temp, y_temp, test_size=0.5)

# Use validation for AutoML
automl.fit(X_train, y_train, X_val, y_val)

# Final evaluation on test set (never seen by AutoML)
final_score = automl.score(X_test, y_test)

6. Document Everything

# AutoML Experiment Log

## Configuration
- Tool: H2O AutoML
- Time limit: 1 hour
- Max models: 20
- CV folds: 5

## Results
- Best model: XGBoost
- Validation score: 0.87
- Test score: 0.85
- Features used: 45/100

## Insights
- Tree-based models performed best
- Feature X was most important
- Adding feature Y improved score by 2%

## Next Steps
- Manual tuning of XGBoost
- Feature engineering based on insights

Key Takeaways

  1. AutoML automates algorithm selection, hyperparameter tuning, and feature engineering
  2. Use for rapid prototyping, baselines, and when expertise is limited
  3. Don't use for highly custom problems, when interpretability is critical
  4. Hybrid approach works best: AutoML baseline + manual optimization
  5. Popular tools: H2O, TPOT, Auto-sklearn, Google AutoML, AutoGluon
  6. Set limits: Time, memory, and model count
  7. Always validate: Use holdout test set, never let AutoML see it
  8. Interpret results: Understand what AutoML found, don't use blindly

Resources


Try next: Run AutoML on a dataset you already modeled by hand. Compare features and failure cases.