Clean messy real-world datasets with safe, explainable defaults before ML.
Project description
datacleaner
ML-safe data cleaning library for real-world datasets.
🚀 Overview
A production-grade Python library that cleans messy datasets using safe, explainable defaults.
- Prevents over-cleaning
- Preserves target column
- Provides transparent transformations
- Tested on 50 datasets
🔥 Key Features
- Full cleaning pipeline
- Target column NEVER modified in clean()
- Explicit target handling via handle_target()
- Smart datatype conversion (₹, %, commas)
- Outlier handling with safeguards
- Skewness handling (only when beneficial)
- Conservative column selection (no aggressive drops)
- Correlation reduction (no cascade deletion)
- Safety guards (row/column loss control)
- Detailed report output
- Validated on 50 datasets
📦 Installation
pip install datacleanr
Package name on PyPI: datacleanr
Import name in code: datacleaner
⚡ Quick Example
from datacleaner import clean, handle_target
df, target_report = handle_target(df, "target", strategy="auto")
cleaned_df, report = clean(df, target_column="target", return_report=True)
🎯 Target Handling
🎯 Target Handling (IMPORTANT)
The clean() function never modifies the target column.
This is intentional to ensure:
- no label corruption
- safe usage in ML pipelines
- predictable behavior
Why?
In real-world ML workflows:
- filling or modifying target values can introduce bias
- automatic changes to labels are unsafe
How to handle target values?
Use the dedicated function:
from datacleaner import handle_target
df, target_report = handle_target(df, "target", strategy="auto")
Behavior:
- If missing values are small -> optional fill (controlled)
- If missing values are large -> rows are dropped
- Fully transparent (reports actions taken)
⚠️ Important
If you skip handle_target():
- target column will remain unchanged
- missing values in target will NOT be handled
This design ensures full user control over label processing.
📊 Skew Handling
- Applied ONLY when it improves distribution
- Safe for negative values
- Never applied to target
- Fully transparent
Example:
{
"feature": {
"before": 1.14,
"after": 0.05,
"method": "log"
}
}
🧠 Feature Selection
- Avoids dropping useful columns
- Prevents cascade correlation deletion
- Keeps column loss controlled, with validation showing no dataset above 25% clean-stage column loss
📈 Validation (IMPORTANT)
- Tested on 50 datasets
- Real datasets + synthetic + edge cases
- 0 failures
- 0 target corruption
- Stable across all scenarios
Validation artifact: tests/validation_50_results.json
📷 Screenshots
📄 Report Example
{
"final_shape": [rows, columns],
"rows_removed_pct": 2.5,
"columns_removed_pct": 8.3,
"integrity_warnings": [],
"skewness_summary": {
"columns_transformed": ["feature_x"],
"details": {
"feature_x": {
"before": 1.14,
"after": 0.05,
"method": "log"
}
}
}
}
⚙️ Design Philosophy
- Conservative over aggressive
- Transparency over automation
- Safety over convenience
🏷 Version
v0.1.3
License
MIT License. See LICENSE.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datacleanr-0.1.4.tar.gz.
File metadata
- Download URL: datacleanr-0.1.4.tar.gz
- Upload date:
- Size: 22.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cf74bf8755a25ec27ec396f31cd9af59e64bbf28f452d8a10896541001429b9
|
|
| MD5 |
f16521baa527725e40c81b13ce82c342
|
|
| BLAKE2b-256 |
29dd550ac055a3b45457b074c80fe8058c17af0ffcbf8f5633c547b407934109
|
File details
Details for the file datacleanr-0.1.4-py3-none-any.whl.
File metadata
- Download URL: datacleanr-0.1.4-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36d47ff3f78b5ad1345497a5df43696189bd943289cc5bd250ae8834850d8016
|
|
| MD5 |
830e0a4289f25e93709eae521be87265
|
|
| BLAKE2b-256 |
1f9075d375a9058ba7d711e73c67f4782d6248174f409c04621e7836821a9625
|