AutoML Toolkit
A framework for building an AutoML System. The toolkit is designed to be modular and extensible, allowing you to easily swap out components and integrate your own. The toolkit is designed to be used in a variety of different ways, whether for research purposes, building your own AutoML Tool or educational purposes.
We focus on building complex parametrized pipelines easily, providing tools to optimize these pipeline parameters and lastly, providing tools to schedule compute tasks on a variety of different compute backends, without the need to refactor everything, once you swap out any one of these.
The goal of this toolkit is to drive innovation for AutoML Systems by:
- Allowing concise research artifacts that can study different design decisions in AutoML.
- Enabling simple prototypes to scale to the compute you have available.
- Providing a framework for building real and robust AutoML Systems that are extensible by design.
Please check out our documentation for more:
- Documentation - The homepage
- Guides - How to use the
Pipelines,OptimizersandSchedulersin a walkthrough fashion. - Reference - A short-overview reference for the various components of the toolkit.
- Examples - A collection of examples for using the toolkit in different ways.
- API - The full API reference for the toolkit.
Installation
To install AutoML Toolkit (amltk), you can simply use pip:
pip install amltk
Install from source
To install from source, you can clone this repo and install with pip:
git clone git@github.com:automl/amltk.git
pip install -e amltk # -e for editable mode
If planning to contribute, you can install the development dependencies but we highly recommend checking out our contributing guide for more.
pip install -e "amltk[dev]"
Features
Here's a brief overview of 3 of the core components from the toolkit:
Pipelines
Define parametrized machine learning pipelines using a fluid API:
from sklearn.ensemble import RandomForestClassifier
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import OneHotEncoder
from sklearn.svm import SVC
from amltk.pipeline import Choice, Component, Sequential
pipeline = (
Sequential(name="my_pipeline")
>> Component(SimpleImputer, space={"strategy": ["mean", "median"]}) # Choose either mean or median
>> OneHotEncoder(drop="first") # No parametrization, no problem
>> Choice(
# Our pipeline can choose between two different estimators
Component(
RandomForestClassifier,
space={"n_estimators": (10, 100), "criterion": ["gini", "log_loss"]},
config={"max_depth": 3},
),
Component(SVC, space={"kernel": ["linear", "rbf", "poly"]}),
name="estimator",
)
)
# Parser the search space with implemented or you custom parser
search_space = pipeline.search_space(parser="configspace")
config = search_space.sample_configuration()
# Configure a pipeline
configured_pipeline = pipeline.configure(config)
# Build the pipeline with a build, no amltk code in your built model
model = configured_pipeline.build(builder="sklearn")
Optimizers
Optimize your pipelines using a variety of different optimizers, with a unified API and a suite of utility for recording and taking control of the optimization loop:
from amltk.optimization import Trial, Metric, History
pipeline = ...
accuracy = Metric("accuracy", maximize=True, bounds=(0. 1))
inference_time = Metric("inference_time", maximize=False)
def evaluate(trial: Trial) -> Trial.Report:
model = pipeline.configure(trial.config).build("sklearn")
try:
# Profile the things you'd like
with trial.profile("fit"):
model.fit(...)
except Exception as e:
# Generate reports from exceptions easily
return trial.fail(exception=e)
# Record anything else you'd like
trial.summary["model_size"] = ...
# Store whatever you'd like
trial.store({"model.pkl": model, "predictions.npy": predictions}),
return trial.success(accuracy=0.8, inference_time=...)
# Easily swap between optimizers, without needing to change the rest of your code
from amltk.optimization.optimizers.smac import SMACOptimizer
from amltk.optimization.optimizers.smac import OptunaOptimizer
import random
Optimizer = random.choice([SMACOptimizer, OptunaOptimizer])
smac_optimizer = Optimizer(space=pipeline, metrics=[accuracy, inference_time], bucket="results")
# You decide how your optimization loop should work
history = History()
for _ in range(10):
trial = optimizer.ask()
report = evaluate(trial)
history.add(report)
optimizer.tell(report)
print(history.df())
Scheduling
Schedule your optimization jobs or AutoML tasks on a variety of different compute backends. By leveraging compute workers and asyncio, you can easily scale your compute needs, react to events as they happen and swap backends, without needing to modify your code!
from amltk.scheduling import Scheduler
# Create a Scheduler with a backend, here 4 processes
scheduler = Scheduler.with_processes(4)
# scheduler = Scheduler.with_SLURM(...)
# scheduler = Scheduler.with_OAR(...)
# scheduler = Scheduler(executor=my_own_compute_backend)
# Define some compute and wrap it as a task to offload to the scheduler
def expensive_function(x: int) -> float:
return (2 ** x) / x
task = scheduler.task(expensive_function)
numbers = range(-5, 5)
results = []
# When the scheduler starts, submit 4 tasks to the processes
@scheduler.on_start(repeat=4)
def on_start():
n = next(numbers)
task.submit(n)
# When the task is done, store the result
@task.on_result
def on_result(_, result: float):
results.append(result)
# Easy to incrementently add more functionallity
@task.on_result
def launch_next(_, result: float):
if (n := next(numbers, None)) is not None:
task.submit(n)
# React to issues when they happen
@task.on_exception
def stop_something_went_wrong(_, exception: Exception):
scheduler.stop()
# Start the scheduler and run it as you like
scheduler.run(timeout=10)
# ... await scheduler.async_run() for servers and real-time applications
Extra Material
Metadata
Release files for amltk 1.12.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| amltk-1.12.1.tar.gz | 174.4 kB | Without provenance | Details for amltk-1.12.1.tar.gz |
Release files / amltk-1.12.1.tar.gz
| Download URL | amltk-1.12.1.tar.gz |
|---|---|
| Size | 174.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89233856f87ecb005070583b37a34fd34d2b5b636a4ef3f89522a5b66ee662de
|
|
BLAKE2b-256 checksum How to use checksums |
9de337f1ae89e6e3040fd144f855a44cc418f5c076af6054ca4a4952fd88a997
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Security for amltk 1.12.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.