Skip to main content

Sanity checks for ML datasets: missing values, class imbalance, and data leakage.

Project description

DatasetSanity ๐Ÿงช

DatasetSanity is a lightweight Python package that helps data scientists and machine learning engineers identify common dataset issues before model training. It performs automated sanity checks on tabular datasets to detect missing values, severe class imbalance, and potential target leakageโ€”issues that often lead to misleading model performance. DatasetSanity provides clear, actionable reports and integrates easily into existing ML workflows.

It helps detect common but critical data issuesโ€”such as missing values, class imbalance, and potential data leakageโ€”before model training.

Fix data problems before the model hides them.

PyPI Python License CI

๐Ÿš€ Why DatasetSanity?

Machine learning models can silently fail or produce misleading results due to poor dataset quality.
DatasetSanity is designed to fail fast by surfacing dataset issues early in the ML pipeline.

It is:

  • โœ… Simple to use
  • โšก Lightweight
  • ๐Ÿ“ฆ Easy to integrate
  • ๐ŸŽ“ Student-friendly
  • ๐Ÿ— Production-ready

โœจ Features

  • ๐Ÿ” Missing Value Analysis

    • Percentage of missing values per column
    • Detection of empty columns and sparse rows
  • โš  Class Imbalance Detection

    • Binary and multi-class classification support
    • Configurable imbalance thresholds
  • ๐Ÿšจ Data Leakage Detection

    • Target-correlated features
    • Duplicate target columns
    • Train-test overlap checks (optional)
  • ๐Ÿ“Š Clear Reports

    • Human-readable console output
    • JSON output for pipelines (HTML planned)

๐Ÿ“ฆ Installation

How to run?

Create a conda environment

conda create -n datasanity python=3.8 -y
conda activate datasanity
pip install -r requirements_dev.txt
pip install datasetsanity

๐Ÿง  Quick Start (Python API)

from DatasetSanity import DatasetSanity
import pandas as pd

df = pd.read_csv("data.csv")

ds = DatasetSanity(
    df=df,
    target="label",
    task="classification"
)

report = ds.run()
report.summary()

๐Ÿ–ฅ Command Line Interface (CLI)

datasetsanity check data.csv --target label

Example output:

โœ” Missing values check passed
โš  Class imbalance detected
โŒ Potential data leakage found

๐Ÿ“„ Report Export

report.to_json("report.json")

(HTML reports planned in future releases.)

๐ŸŽฏ Use Cases

  • ML students validating datasets
  • Data scientists performing pre-model checks
  • ML engineers integrating dataset validation into pipelines
  • Educators teaching data quality concepts

๐Ÿ“ Project Structure

DataSetSanity-PyPi-Package/
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ”œโ”€โ”€ .gitkeep
โ”‚       โ””โ”€โ”€ ci.yml
โ”œโ”€โ”€ docs/                # optional documentation
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ datasetsanity/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ custom_exception.py
โ”‚       โ”œโ”€โ”€ logger.py
โ”‚       โ””โ”€โ”€ py.typed
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ unit/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ test_unit.py
โ”‚   โ””โ”€โ”€ integration/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ””โ”€โ”€ test_int.py
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ MANIFEST.in
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ requirements_dev.txt
โ”œโ”€โ”€ setup.py
โ”œโ”€โ”€ setup.cfg
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ template.py           # cookiecutter template
โ”œโ”€โ”€ pypi.ipynb            # PyPI release notebook
โ”œโ”€โ”€ pypi.excalidraw       # PyPI release diagram
โ”œโ”€โ”€ tox.ini
โ””โ”€โ”€ test.py              # sandbox testing

๐Ÿ›ฃ Roadmap

  • Regression task support
  • Feature drift detection
  • HTML & visual reports
  • sklearn pipeline integration
  • CI/CD dataset checks

๐Ÿค Contributing

Contributions are welcome! Please read CONTRIBUTING.md before submitting issues or pull requests.

๐Ÿ“„ License

This project is licensed under the MIT License. See LICENSE for details.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datasetsanity-0.0.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datasetsanity-0.0.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file datasetsanity-0.0.1.tar.gz.

File metadata

  • Download URL: datasetsanity-0.0.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for datasetsanity-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8f7985a9f8eb5e2cdcafdcf3cef4e9e5783dc5b23fcb6e259579292fece44661
MD5 e8fec86fb16c388efb01b1e90a49edfa
BLAKE2b-256 a1b7f6b820cf33499530d77b4ed728aefcdce8261e37d35e907dff957dc02ade

See more details on using hashes here.

File details

Details for the file datasetsanity-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: datasetsanity-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for datasetsanity-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0fa13e9be605713d4eb6451c3b01c1c57eec46cc2b0686e4cb54dddc1f0e2a3a
MD5 5fc706faa8db89f95ccc12ab1e5961d9
BLAKE2b-256 a4ccbb6fd44c6164aec9989e9eb68827db0623b98bfe9d83ae8b4c1d16f2a5c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page