Simple data preprocessing utilities for tabular data
Project description
EasyPrep
EasyPrep is a lightweight, NumPy-based preprocessing library that dramatically reduces boilerplate code in machine learning pipelines. It provides a unified interface for common data preprocessing tasks including missing value imputation, outlier handling, skewness correction, and feature scaling.
Built with pure Python and NumPy, EasyPrep offers efficient preprocessing without heavy dependencies, making it ideal for projects where you need scikit-learn-like functionality with minimal overhead.
Why EasyPrep?
- Unified Interface: One object (
Easyprep) handles multiple preprocessing steps - Minimal Dependencies: Built with pure NumPy and Python
- Sklearn-Compatible API: Familiar
fit()andtransform()methods - Lightweight: Significantly smaller footprint than full ML frameworks
- Flexible: Use the main class or individual preprocessing components
- Type-Safe: Full type hints for better IDE support
Installation
pip install ez-easyprep
From source:
git clone https://github.com/CraftyCode121/easyprep.git
cd easyprep
pip install -e .
Quick Start
import numpy as np
from easyprep import Easyprep
# Sample data with missing values and outliers
X = np.array([
[1.0, 2.0, 100.0],
[2.0, np.nan, 3.0],
[3.0, 4.0, 5.0],
[np.nan, 5.0, 1000.0], # outlier
[5.0, 6.0, 7.0]
])
# Initialize with default settings
prep = Easyprep(
imputer='mean',
outlier_handler='replace_mean',
skew_handler='auto',
scaler='standard-scaler'
)
# Fit and transform
X_clean = prep.fit_transform(X)
print(X_clean)
# Output: Preprocessed array with imputed values, handled outliers,
# corrected skewness, and scaled features
Core Concepts
EasyPrep follows the fit-transform pattern common in scikit-learn:
- Fit: Learn parameters from training data (means, quantiles, scale factors, etc.)
- Transform: Apply learned transformations to data
- Fit-Transform: Convenience method combining both steps
The library processes data in a specific order:
- Missing Value Imputation → Fill NaN values
- Outlier Handling → Detect and handle outliers using IQR method
- Skewness Correction → Apply transformations to reduce skewness
- Scaling → Normalize or standardize features
API Reference
Main Class: Easyprep
The primary interface for streamlined preprocessing.
from easyprep import Easyprep
prep = Easyprep(
imputer='mean', # How to fill missing values
outlier_handler='clip', # How to handle outliers
skew_handler='auto', # How to handle skewness
scaler='standard-scaler' # How to scale features
)
Parameters:
-
imputer(str, optional): Strategy for handling missing values- Options:
None,'mean','median','most_frequent','constant' - Default:
'mean'
- Options:
-
outlier_handler(str, optional): Strategy for handling outliers- Options:
None,'clip','remove','replace_mean','replace_median','replace_nan' - Default:
'replace_mean'
- Options:
-
skew_handler(str, optional): Strategy for correcting skewness- Options:
None,'log','sqrt','boxcox','yeo-johnson','auto' - Default:
'auto'
- Options:
-
scaler(str, optional): Strategy for feature scaling- Options:
None,'standard-scaler','minmax-scaler' - Default:
'standard-scaler'
- Options:
Methods:
fit(X): Learn preprocessing parameters from datatransform(X): Apply preprocessing transformationsfit_transform(X): Fit and transform in one step
Individual Preprocessing Components
For fine-grained control, use individual preprocessing classes:
SimpleImputer
Fill missing values using various strategies.
from easyprep.preprocess import SimpleImputer
imputer = SimpleImputer(strategy='mean', fill_value=None)
X_imputed = imputer.fit_transform(X)
Parameters:
strategy:'mean','median','most_frequent', or'constant'fill_value: Value to use whenstrategy='constant'
IQROutlierHandler
Detect and handle outliers using the Interquartile Range (IQR) method.
from easyprep.preprocess import IQROutlierHandler
outlier_handler = IQROutlierHandler(method='clip', k=1.5)
X_clean = outlier_handler.fit_transform(X)
Parameters:
method:'clip','remove','replace_mean','replace_median', or'replace_nan'k: IQR multiplier for outlier detection (default: 1.5)
SkewHandler
Reduce feature skewness using various transformations.
from easyprep.preprocess import SkewHandler
skew_handler = SkewHandler(method='auto', threshold=0.5)
X_transformed = skew_handler.fit_transform(X)
Parameters:
method:'log','sqrt','boxcox','yeo-johnson', or'auto'threshold: Skewness threshold for automatic transformation (default: 0.5)
StandardScaler
Standardize features by removing mean and scaling to unit variance.
from easyprep.preprocess import StandardScaler
scaler = StandardScaler(with_mean=True, with_std=True, copy=True)
X_scaled = scaler.fit_transform(X)
Parameters:
with_mean: Center data before scalingwith_std: Scale data to unit variancecopy: Create a copy of input data
MinMaxScaler
Scale features to a specified range.
from easyprep.preprocess import MinMaxScaler
scaler = MinMaxScaler(feature_range=(0, 1))
X_scaled = scaler.fit_transform(X)
Parameters:
feature_range: Tuple specifying the desired range (default: (0, 1))
Usage Examples
Example 1: Basic Pipeline
import numpy as np
from easyprep import Easyprep
# Create sample data
X_train = np.array([
[1, 2, 3],
[4, np.nan, 6],
[7, 8, 9],
[10, 11, 1000] # outlier
])
X_test = np.array([
[2, 3, 4],
[5, np.nan, 7]
])
# Initialize preprocessor
prep = Easyprep()
# Fit on training data
prep.fit(X_train)
# Transform both training and test data
X_train_clean = prep.transform(X_train)
X_test_clean = prep.transform(X_test)
Example 2: Custom Configuration
from easyprep import Easyprep
# Configure for a specific use case
prep = Easyprep(
imputer='median', # Use median for robustness
outlier_handler='clip', # Clip outliers to IQR bounds
skew_handler='yeo-johnson', # Handle negative values
scaler='minmax-scaler' # Scale to [0, 1] range
)
X_processed = prep.fit_transform(X)
Example 3: Disable Specific Steps
from easyprep import Easyprep
# Only impute and scale, skip outlier and skew handling
prep = Easyprep(
imputer='mean',
outlier_handler=None, # Skip outlier handling
skew_handler=None, # Skip skewness correction
scaler='standard-scaler'
)
X_processed = prep.fit_transform(X)
Example 4: Using Individual Components
from easyprep.preprocess import SimpleImputer, StandardScaler
# Build custom pipeline
imputer = SimpleImputer(strategy='median')
scaler = StandardScaler()
# Apply sequentially
X_imputed = imputer.fit_transform(X)
X_scaled = scaler.fit_transform(X_imputed)
Example 5: Handling Different Data Types
import numpy as np
from easyprep import Easyprep
# Mixed data with various issues
X = np.array([
[1.5, 2.0, 100],
[2.5, np.nan, 200],
[np.nan, 4.0, 150],
[4.5, 5.0, 99999], # extreme outlier
[5.5, 6.0, 175]
])
prep = Easyprep(
imputer='mean',
outlier_handler='replace_median',
skew_handler='auto',
scaler='standard-scaler'
)
X_clean = prep.fit_transform(X)
Project Structure
easyprep/
├── easyprep/
│ ├── __init__.py # Package initialization
│ ├── core.py # Main Easyprep class
│ └── preprocess/ # Preprocessing components
│ ├── __init__.py
│ ├── nan_handler.py # SimpleImputer
│ ├── outlier_handler.py # IQROutlierHandler
│ ├── scaler.py # StandardScaler, MinMaxScaler
│ └── skew_handler.py # SkewHandler
├── tests/
│ ├── __init__.py
│ └── test_core.py # Unit tests
├── pyproject.toml # Project metadata
└── README.md # This file
Requirements
- Python: 3.7+
- NumPy: 2.4+
Error Handling
EasyPrep validates all parameters at initialization:
from easyprep import Easyprep
# This will raise ValueError
try:
prep = Easyprep(imputer='invalid_strategy')
except ValueError as e:
print(e) # "Invalid imputer. Must be one of [None, 'mean', 'median', ...]"
Testing
EasyPrep uses pytest for testing. To run tests:
# Install development dependencies
pip install pytest
# Run tests
pytest tests/
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Inspired by scikit-learn's preprocessing module
- Built for developers who need lightweight, efficient preprocessing
- Designed with simplicity and performance in mind
Support
- Issues: GitHub Issues
Made with LO❤️E by Hassan Rasheed, for developers
Project details
Release history Release notifications | RSS feed
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 ez_easyprep-1.1.0.tar.gz.
File metadata
- Download URL: ez_easyprep-1.1.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42e3d4c775af9cb55c31ae603e94f147fd32c39ff90af5ca048069704ffbad41
|
|
| MD5 |
12ea8078478164a03b68e2295905ef93
|
|
| BLAKE2b-256 |
0301807a9962d32745a143ffed2e3c1d1c8e7ed55eddabade4850fcc333a2748
|
File details
Details for the file ez_easyprep-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ez_easyprep-1.1.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4545c102e51742c8fbd82fe12f8cd9600f6057fa6dd011419886fef4845db940
|
|
| MD5 |
a412048feb23bbdc837d356924236ee7
|
|
| BLAKE2b-256 |
cbb114e6e6c9239d79d4e5b2636b230c97043640c92a789cc30123f3b7866870
|