Smart Impute: adaptive per-column missing value imputation
Project description
Smart Imputation
Simpute is an adaptive missing-value imputation library for tabular data. Instead of applying one global strategy to every column, it profiles each feature, selects a tailored model, and imputes columns sequentially so earlier fills inform later ones.
Install from PyPI as simpute. Source and releases live at github.com/Hvllvix/Simpute.
Why Simpute
Most imputers pick a single method (mean, median, MICE, KNN) for the whole table. Real datasets mix binary flags, low-cardinality categories, high-cardinality text-like fields, skewed counts, and smooth continuous variables. Simpute treats each column on its own terms.
| Core Architectural Dimension | Simpute Engine Standard |
|---|---|
| Profiling Strategy | Granular per-column analysis and dynamic routing |
| API Compliance | Native Scikit-learn interface (fit / transform / fit_transform) |
| Algorithmic Suite | LightGBM, CatBoost, Regularized Logistic/SVC, KNN, Bayesian Ridge, Extra Trees |
| System Integrity | Integrated firewall guard suite featuring ground-truth precision verification |
| Fault Tolerance | Automated warnings and flags for columns exceeding 70% missingness thresholds |
Installation
pip install simpute
Development install with tests and plotting extras:
git clone [https://github.com/Hvllvix/Simpute.git](https://github.com/Hvllvix/Simpute.git)
cd Simpute
pip install -e ".[dev]"
Quick Start
import pandas as pd
from simpute import Simpute
df = pd.read_csv("data.csv")
imputer = Simpute(exclude=["Student_ID"])
filled = imputer.fit_transform(df)
print(imputer.getmodelselection())
print(imputer.getprofiles())
exclude keeps identifier columns out of the imputation loop. Use columns=[...] instead when you only want to impute a subset.
How It Works
- Profile each target column (type, missingness, cardinality, distribution shape).
- Select features with mutual information (top 6 predictors by default).
- Route to a candidate model based on the column profile.
- Fit on observed rows, then impute missing cells column by column.
- Warn when missingness exceeds 70% on a column.
Sequential imputation means numerical columns are generally filled before categorical ones, and values imputed in earlier columns become features for later columns.
Model Selection
| Target Column Profile | Underlying Statistical Property | Optimized Backend Algorithm |
|---|---|---|
| High-Cardinality Categorical | Large nominal domains, text-like properties | CatBoostClassifier / LightGBMClassifier |
| Low-Cardinality / Binary | Binary indicators, low unique nominal categories | LogisticRegression (L2) / LinearSVC |
| Large Numerical Tables | Datasets exceeding 1,000 observations | LightGBMRegressor / ExtraTreesRegressor |
| Skewed / Discrete Numerical | Long-tailed metrics, highly unbalanced distributions | LightGBMRegressor / ExtraTreesRegressor |
| Normal / Uniform Continuous | Symmetric, un-skewed numerical continuous shapes | KNNRegressor / BayesianRidge |
Inspect the chosen backend per column after fitting:
imputer.getmodelselection()
# {'Pre_Semester_GPA': 'LGBMRegressor', 'Major_Category': 'CatBoostClassifier', ...}
API Reference
| Interface Method | Return Signature | Functional Description |
|---|---|---|
fit(df) |
self |
Profiles columns and trains tailored per-column machine learning architectures. |
transform(df) |
pd.DataFrame |
Executes sequential imputation calculations using previously fitted backend models. |
fit_transform(df) |
pd.DataFrame |
Runs profiling, model training, and cell imputation in a single optimized pass. |
getprofiles() |
dict |
Exposes the underlying metadata mapping generated during the dataset profiling phase. |
getmodelselection() |
dict |
Returns the specific machine learning model mapped to each target imputed column. |
Constructor options: columns, exclude, maskratio, randomstate.
Guard Tests
The guard suite (tests/guard.py) masks values in tests/data/test.csv, imputes them, and checks:
- No NaN values remain after imputation
- Categorical predictions stay within the original domain
- Numerical predictions stay within bounded ranges
- Imputation beats adaptive random baselines on held-out masked cells
- Model selection is deterministic and profile-consistent
- High-missingness columns emit warnings
transformbeforefitraisesRuntimeError
See tests/data/README.md for column descriptions and how to swap in your own CSV.
pytest tests/guard.py -v
Metric summary table (MAE for continuous columns, accuracy for nominal):
python tests/guard.py
Validation Plots
Generated on the bundled test dataset (MASKRATIO=0.15, SEED=42):
| Target Asset Graphic | Metric Visualization Type | Core Analytical Purpose |
|---|---|---|
| Imputation Density | Kernel Density Estimation (KDE) | Compares baseline vs post-imputation distributions to verify variance preservation. |
| Missingness Heatmap | Binary Feature Completeness Grid | Displays visual evidence of structural integrity before and after complete table imputation. |
| Model Allocation | Horizontal System Flow Chart | Provides full clarity into how columns were programmatically routed to distinct algorithms. |
Regenerate locally:
python scripts/generate_plots.py
Requirements
- Python 3.10+
- NumPy, Pandas, SciPy, scikit-learn, LightGBM, CatBoost
Contributing
- Fork Hvllvix/Simpute
- Create a branch, make changes, run
pytest tests/guard.py -v - Open a pull request
License
MIT
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 simpute-0.1.2.tar.gz.
File metadata
- Download URL: simpute-0.1.2.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
348974d3da8b9a30a88ae7a2ce660e843776c89220562902e8e1ae19e4ee27ee
|
|
| MD5 |
462720b0759ebe08e99a50e564bf05ca
|
|
| BLAKE2b-256 |
9bf428358447bf057acca47328d534a42e9778cad4d2ef8af11ea0c9df99534b
|
Provenance
The following attestation bundles were made for simpute-0.1.2.tar.gz:
Publisher:
release.yml on Hvllvix/Simpute
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simpute-0.1.2.tar.gz -
Subject digest:
348974d3da8b9a30a88ae7a2ce660e843776c89220562902e8e1ae19e4ee27ee - Sigstore transparency entry: 2046983329
- Sigstore integration time:
-
Permalink:
Hvllvix/Simpute@210b2ec9cd52778a3090aee7a692beb85035e096 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Hvllvix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@210b2ec9cd52778a3090aee7a692beb85035e096 -
Trigger Event:
release
-
Statement type:
File details
Details for the file simpute-0.1.2-py3-none-any.whl.
File metadata
- Download URL: simpute-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7e16116cc8489fa8f6db050bf5d2887c763d762fd69eaac614d502cd3ad7379
|
|
| MD5 |
4d06218ad491d1687d3ad2bdddbe0904
|
|
| BLAKE2b-256 |
3be725d0884f39736c26a7d379678d8ef1416c3e81e1054cf3d74cad9a3fd65a
|
Provenance
The following attestation bundles were made for simpute-0.1.2-py3-none-any.whl:
Publisher:
release.yml on Hvllvix/Simpute
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simpute-0.1.2-py3-none-any.whl -
Subject digest:
f7e16116cc8489fa8f6db050bf5d2887c763d762fd69eaac614d502cd3ad7379 - Sigstore transparency entry: 2046983378
- Sigstore integration time:
-
Permalink:
Hvllvix/Simpute@210b2ec9cd52778a3090aee7a692beb85035e096 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Hvllvix
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@210b2ec9cd52778a3090aee7a692beb85035e096 -
Trigger Event:
release
-
Statement type: