OpenML
Sign In
v1.0

OpenML APIs

OpenML provides a unified interface to access machine learning resources across multiple programming languages. Whether you're exploring datasets, running experiments, or benchmarking algorithms, our APIs make it easy to integrate OpenML into your workflow.

10,000+ Datasets

Access curated ML datasets with rich metadata

50,000+ Tasks

Pre-defined ML tasks with standardized evaluation

10M+ Runs

Reproducible experiments and benchmarks

Getting Started

Installation

The Python API provides the most comprehensive access to OpenML functionality, with full support for scikit-learn, PyTorch, and TensorFlow.

Installation

terminal
pip install openml

Example

example.py
1
2
3
4
5
6
7
import openml
# Configure your API key (optional for read-only access)
openml.config.apikey = 'YOUR_API_KEY'
# Verify installation
print(f"OpenML version: {openml.__version__}")

Authentication

How to get your API key:

  1. 1Create an OpenML account or sign in if you already have one
  2. 2Go to your API Key page in your account settings
  3. 3Copy your API key and store it securely (never share it publicly!)
Configuration
# Store your API key securely
# Option 1: Environment variable (recommended)
export OPENML_APIKEY="your_api_key_here"

# Option 2: Config file (~/.openml/config)
apikey = your_api_key_here

# Option 3: Set in code (not recommended for shared code)
import openml
openml.config.apikey = "your_api_key_here"

Client Libraries

Python
Most comprehensive API
scikit-learnPyTorchTensorFlow

Full-featured Python client with integrations for popular ML frameworks. Best choice for most users.

R
Statistical computing
mlr3tidymodelsCRAN

R package with seamless integration for mlr3 and the R machine learning ecosystem.

Java
JVM applications
WekaMOAMaven

Java connector for enterprise applications and Weka/MOA integration.

Working with Data

Datasets

OpenML hosts thousands of curated ML datasets. Each dataset includes rich metadata, feature descriptions, and quality metrics.

Example

example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import openml
# Get a dataset by name or ID
dataset = openml.datasets.get_dataset("credit-g") # or get_dataset(31)
# Access the data
X, y, categorical_indicator, attribute_names = dataset.get_data(
target="class"
)
# List available datasets
datasets = openml.datasets.list_datasets(output_format="dataframe")
print(f"Found {len(datasets)} datasets")
# Search for specific datasets
filtered = datasets[datasets['NumberOfInstances'] > 1000]

Tasks

Tasks combine a dataset with a problem type (classification, regression, etc.) and evaluation procedure (cross-validation folds).

Example

example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import openml
# Get a task (supervised classification on credit-g)
task = openml.tasks.get_task(31)
# Access task properties
print(f"Task type: {task.task_type}")
print(f"Dataset: {task.dataset_id}")
print(f"Target: {task.target_name}")
# Get train/test splits
train_indices, test_indices = task.get_train_test_split_indices(fold=0)
# List available tasks
tasks = openml.tasks.list_tasks(output_format="dataframe")

Runs & Experiments

Runs capture the complete record of an ML experiment: the algorithm used, hyperparameters, predictions, and evaluation metrics.

Example

example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import openml
from sklearn.ensemble import RandomForestClassifier
# Get a task
task = openml.tasks.get_task(31)
# Create and run a model
clf = RandomForestClassifier(n_estimators=100, random_state=42)
run = openml.runs.run_model_on_task(clf, task)
# Upload results to OpenML
run.publish()
print(f"Run ID: {run.run_id}")
# View evaluation results
for metric, value in run.fold_evaluations.items():
print(f"{metric}: {value}")

Benchmarking

OpenML provides curated benchmark suites for standardized algorithm evaluation. Run your models on established benchmarks to compare with state-of-the-art methods.

OpenML-CC18

72 classification datasets

72 tasks

AutoML Benchmark

Standard AutoML evaluation

104 tasks

Example

example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import openml
# Get a benchmark suite
suite = openml.study.get_suite("OpenML-CC18") # Classification benchmark
# Iterate over tasks in the suite
for task_id in suite.tasks:
task = openml.tasks.get_task(task_id)
print(f"Task {task_id}: {task.get_dataset().name}")
# Run your model on the entire benchmark
from sklearn.ensemble import GradientBoostingClassifier
for task_id in suite.tasks[:5]: # First 5 tasks
task = openml.tasks.get_task(task_id)
clf = GradientBoostingClassifier()
run = openml.runs.run_model_on_task(clf, task)
run.publish()

Rate Limits

Read operations~1000 requests/hour
Write operations~100 requests/hour
Bulk downloadsContact us for higher limits

REST API

For advanced users who need direct HTTP access, OpenML provides a comprehensive REST API. The API is language-agnostic and can be used from any environment.

Base URL: https://www.openml.org/api/v1/

Supports both JSON and XML response formats. Authentication via API key is required for write operations.

View Swagger Documentation

Additional Resources