UCI ML Repository Python Wrapper

0.0.7 · active · verified Fri Apr 17

The `ucimlrepo` library provides a simple interface to programmatically fetch and load datasets from the UC Irvine Machine Learning Repository directly into Python scripts and notebooks. It retrieves data, metadata, and variable information, primarily returning data as pandas DataFrames. As of version 0.0.7, it is actively maintained with a relatively stable but evolving API, ideal for machine learning and data science workflows.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to fetch a dataset using its unique ID, access its features and targets as pandas DataFrames, and retrieve metadata and variable information. Replace `id=53` with the ID of any dataset from the UCI ML Repository.

from ucimlrepo import fetch_ucirepo

# Fetch a dataset by its ID (e.g., Iris dataset, ID 53)
iris_dataset = fetch_ucirepo(id=53)

# Access features (X) and targets (y) as pandas DataFrames
X = iris_dataset.data.features
y = iris_dataset.data.targets

print("Features (X) head:\n", X.head())
print("Targets (y) head:\n", y.head())

# Access metadata and variable information
print("\nMetadata:\n", iris_dataset.metadata)
print("\nVariable Info:\n", iris_dataset.variables)

view raw JSON →