OpenML-Python: Collaborative Machine Learning API for Data Sharing

Jul 10, 2025

Introduction

Finding high-quality, reproducible datasets for machine learning is often a fragmented process involving manual downloads and inconsistent formatting. OpenML-Python is a Python API that solves this by providing a direct connector to the OpenML platform, allowing developers to programmatically access thousands of datasets and share their experiment results. By integrating seamlessly with the scientific Python stack, it transforms the way researchers and developers handle data and benchmark their models.

What Is OpenML-Python?

OpenML-Python is a Python library that provides a straightforward interface for interacting with OpenML, an online platform for open science collaboration in machine learning. It allows users to download datasets, define research goals (tasks), and upload machine learning experiment results (runs) to the platform.

Maintained by the OpenML organization and licensed under the BSD 3-Clause License, the library is designed to be lightweight and integrates deeply with numpy, scipy, and pandas. It is specifically optimized for use with scikit-learn, enabling users to run models on OpenML tasks and publish their results online with minimal code changes.

Why OpenML-Python Matters

In traditional machine learning workflows, sharing a dataset or a model’s performance on a specific split of data is a manual and error-prone process. OpenML-Python eliminates this friction by treating datasets, tasks, and runs as first-class objects. This allows for true reproducibility: any researcher can pull the exact same dataset version and the same train-test split indices to verify a result.

The library has gained significant traction in the AutoML community and scientific research, as it provides a standardized way to benchmark models across a curated list of tasks. Instead of manually managing CSV files, developers can use OpenML-Python to automate the retrieval of benchmarking suites, making the evaluation of new algorithms more rigorous and transparent.

Key Features

  • Dataset Management: Programmatically query and download datasets from OpenML using either their unique ID or name. This removes the need for manual downloads and ensures the data is loaded directly into a pandas DataFrame.
  • Task-Based Benchmarking: Access predefined tasks that specify the target attribute and the cross-validation split. This ensures that when you compare two models, you are comparing them on the exact same data splits.
  • Scikit-Learn Integration: Run scikit-learn estimators or pipelines directly on OpenML tasks. The library handles the data fetching and evaluation, allowing you to publish the run results to the server with a single method call.
  • Experiment Sharing: eğitimler: Upload your model’s hyperparameters, the flow (pipeline) used, and the evaluation metrics to OpenML. This creates a public record of your experiment, which others can reuse or improve upon.
  • Benchmarking Suites: Access curated lists of tasks (suites) to perform large-scale evaluations of machine learning algorithms across diverse data types.
  • Extensible Architecture: The library is designed as a connector. Other machine learning libraries (like PyTorch or TensorFlow) can be integrated via separate connector packages to keep the core library lightweight.

How OpenML-Python Compares

Feature OpenML-Python sklearn.datasets Kaggle API
Dataset Access Dynamic (API-based) Static (Built-in/Fetch) Dynamic (API-based)
Experiment Tracking Native (Runs/Flows) None None
Reproducibility High (Fixed Splits) Moderate Low (Manual)
Collaboration Public Publishing None Competition-based

While sklearn.datasets is excellent for beginners and toy datasets, it lacks the infrastructure for sharing and tracking experiments. The Kaggle API allows for easy dataset retrieval, but it does not provide the standardized “Task” concept that OpenML-Python uses to ensure that different models are evaluated on the same data splits. OpenML-Python is the only tool in this group that creates a closed-loop system for the entire ML lifecycle: from data retrieval to result publishing.

Getting Started: Installation

Standard Installation

OpenML-Python is supported on Python 3.8 through 3.13 and is available for Linux, MacOS, and Windows. The simplest way to install the library is via pip:

pip install openml

Docker Installation

For those who prefer isolated environments, OpenML provides a pre-configured Docker image that includes the library and its dependencies:

docker pull openml/openml-python
docker run -it openml/openml-python

Prerequisites

To publish results or upload datasets, you will need an API key. You can obtain one by signing up for a free account at OpenML.org. Once you have your key, you can authenticate permanently using the CLI:

openml configure apikey YOUR_API_KEY

How to Use OpenML-Python

The basic workflow in OpenML-Python revolves around the datasets, tasks, and runs modules. To get started, you first retrieve a dataset by its name or ID. Once you have the dataset, you can either use the data directly or retrieve a specific task associated with that dataset.

A task defines the target variable and the split indices for training and testing. By using a task, you can ensure that your model’s performance is compared against others on the same exact data. After running your model, you can use the run_model_on_task function to automate the evaluation and create a run object that can be published to the OpenML server.

Code Examples

Example 1: Downloading a Dataset

This example shows how to retrieve the “credit-g” dataset and extract the features and target variable as a pandas DataFrame.

import openml

# Get dataset by name
dataset = openml.datasets.get_dataset("credit-g")

# Extract data
X, y, categorical_indicator, attribute_names = dataset.get_data(target="class")

print(X.head())

Example 2: Running a Model on a Task

This example demonstrates how to use a scikit-learn pipeline to solve a specific OpenML task and publish the results.

import openml
from sklearn import pipeline, tree, impute

# Define a scikit-learn pipeline
clf = pipeline.Pipeline(
    steps=[
        ('imputer', impute.SimpleImputer()),
        ('estimator', tree.DecisionTreeClassifier())
    ]
)

# Download the OpenML task for the pendigits dataset
task = openml.tasks.get_task(32)

# Run the scikit-learn model on the task
run = openml.runs.run_model_on_task(clf, task)

# Publish the experiment to OpenML (requires API key)
run.publish()

print(f"View the run online: {run.openml_url}")

Advanced Configuration

OpenML-Python uses a configuration file located at ~/.openml/config. This file consists of key-value pairs that allow you to customize the library’s behavior. Common configuration options include:

  • apikey: Your personal API key for authentication.
  • server: The server to connect to. By default, this is http://www.openml.org, but you can change it to test.openml.org for development and testing.
  • cachedir: The root folder where the library caches downloaded datasets and tasks to avoid redundant network requests.
  • avoid_duplicate_runs: If set to True, the library will check if an identical run already exists on the server before executing the model, downloading the results instead of re-running it.

Real-World Use Cases

1. Academic Research and Reproducibility: Researchers can use OpenML-Python to share their datasets and the exact train-test splits used in their papers. This allows other scientists to exactly replicate the results of a published study without having to guess the split indices or search for CSV files.

2. AutoML Benchmarking: Developers of new AutoML frameworks can use the OpenML benchmarking suites to evaluate their system’s performance across 100+ datasets. This provides a standardized, automated way to prove the state-of-the-art performance of a new algorithm.

3. Collaborative Data Curation: Teams can use the platform to maintain a shared repository of curated datasets, where each version of the dataset is tracked. This ensures that all team members are working with the same version of the data, preventing “data drift” during the same project.

Contributing to OpenML-Python

The OpenML community encourages contributions to the library. All contributions should be linked to an issue on the GitHub issue tracker. New contributors are encouraged to look for the good first issue label to find tasks suitable for beginners.

The project follows a standard GitHub flow: report a bug or request a feature via an issue, then submit a pull request. The project also provides a detailed CONTRIBUTING.md file in the repository for specific guidelines on writing extensions.

The maintainers emphasize the use of continuous integration for Windows and Linux to ensure that new changes do not break existing functionality. The project also provides a detailed CONTRIBUTING.md file in the repository for specific guidelines on writing extensions.

Community and Support

OpenML-Python is part of a larger ecosystem. Official support and documentation can be found at the OpenML Documentation site. For real-time collaboration and community discussion, the project maintains a Slack channel and hosts regular meetups.

The primary hub for technical support is the GitHub Discussions and Issues tabs of the openml-python repository. The community is highly active in the open science movement, java and R APIs are also available for those working outside the Python ecosystem.

Conclusion

OpenML-Python is an essential tool for anyone serious about reproducible machine learning. By bridging the gap between local development and a global collaborative platform, it removes the friction of manual data management and the laziest form of “reproducibility” (sharing a CSV file). It is the right choice when you need to benchmark models across multiple datasets or when you publish research that requires absolute transparency.

While the library is lightweight and integrates well with scikit-learn, users should be aware that it is a connector to a remote server. Therefore, network latency and server availability can impact the performance of data retrieval. For those who can the best approach is to use the local cache configuration to optimize the performance.

Star the repo, try the quickstart, and join the OpenML community to start sharing your ML experiments today.

What is OpenML-Python and what problem does it solve?

OpenML-Python is a Python API that connects to the OpenML platform, solving the problem of fragmented and non-reproducible machine learning experiments. It allows developers to programmatically download datasets and share their model results, ensuring that everyone uses the same data splits and versions.

How do I install OpenML-Python?

You can install the library using pip with the command pip install openml. For isolated environments, you can also use the official Docker image openml/openml-python.

How does OpenML-Python compare to sklearn.datasets?

While sklearn.datasets provides a few built-in datasets, OpenML-Python provides access to thousands of dynamic datasets and allows you to publish your results back to the server, whereas sklearn.datasets is a static library for local loading.

Can I use OpenML-Python for deep learning with PyTorch or TensorFlow?

Yes, you can use OpenML-Python to download the data as pandas DataFrames, which can then be converted into tensors for use in PyTorch or TensorFlow. The platform also has separate connector packages for these libraries to further streamline the integration.

Do I need an API key to use OpenML-Python?

You can download datasets and tasks without an API key, but you need one to upload datasets, publish runs, or manage your own data on the platform.

What is an OpenML 'Task' and why is it important?

A task is a predefined set of evaluation criteria, including the target attribute and the train-test split indices. This is crucial for reproducibility because it ensures that different models are compared on the exact same data splits.

Is OpenML-Python open source?

Yes, OpenML-Python is open source and licensed under the BSD 3-Clause License, making it available for anyone to use, modify, and redistribute.