Imputation Methods¶
A unified pandas API for 42 missing-data imputation methods: statistical, time-series, regression, ensemble and matrix-completion.
Overview¶
Missing data is a common challenge in data science and machine learning. imputation-methods provides a unified interface for comparing and evaluating different imputation strategies, from simple statistical methods to advanced machine learning approaches.
Features¶
โจ 42 Imputation Methods - From mean/median to MICE, MissForest and SoftImpute
๐ฏ Unified API - Every imputer exposes impute(df), and each has a functional shortcut such as mean_impute(df)
๐ Type-Safe - Full type hints (ships py.typed), checked with mypy in strict mode
๐ Evaluation Metrics - RMSE, MAE for quality assessment
๐งช Well-Tested - Test suite and doctests run in CI on Python 3.10โ3.14
๐ Extensive Documentation - Tutorials, examples, and API docs
Quick Example¶
import pandas as pd
import numpy as np
from imputation_methods import KNNImputer
# Create data with missing values
df = pd.DataFrame({
'feature1': [1.0, 2.0, np.nan, 4.0, 5.0],
'feature2': [5.0, np.nan, np.nan, 8.0, 10.0],
})
# Apply KNN imputation
imputer = KNNImputer(n_neighbors=3)
df_imputed = imputer.impute(df)
print(df_imputed)
Available Methods¶
Statistical Methods¶
- Mean, Median, Mode Imputation
- Constant, Quantile and Trimmed Mean Imputation
- End-of-Distribution Imputation
- Group Mean/Median Imputation
- Missing Indicator + Imputation
Sampling Methods¶
- Random Sampling
- Hot Deck
- Cold Deck
Time Series Methods¶
- LOCF (Last Observation Carried Forward)
- NOCB (Next Observation Carried Backward)
- Forward Fill with Mean/Median Fallback
- Interpolation (linear, polynomial, spline)
- Moving Average and Exponentially Weighted Moving Average
- Linear and Polynomial Trend
- Seasonal Imputation
- Kalman Filter
Distance-Based Methods¶
- K-Nearest Neighbors
- Radius Neighbors
- Local Weighted Mean
Regression-Based Methods¶
- Linear Regression
- Stochastic Regression
- Predictive Mean Matching (PMM)
- Bayesian Ridge
- Huber and RANSAC Robust Regression
- Gaussian Process
Iterative Methods¶
- MICE (Multiple Imputation by Chained Equations)
- MissForest
- EM-style iterative imputation (chained equations, not closed-form multivariate-normal EM)
Matrix Completion Methods¶
- SoftImpute
- Bayesian PCA (maximum-likelihood probabilistic PCA)
Neural Network Methods¶
- Autoencoder
- GAIN (Generative Adversarial Imputation Nets)
Ensemble Methods¶
- Hybrid (fallback chain)
- Stacking (mean/median of several imputers)
- Bagging (bootstrap aggregating of a base imputer)
Installation¶
Next Steps¶
-
Getting Started
Learn the basics with our comprehensive tutorial
-
User Guide
Explore the imputation methods and when to use them
-
Examples
See practical examples for real-world scenarios
-
API Reference
Detailed API documentation for all methods
Community¶
- GitHub: Issues and Discussions
- Email: diogo.debastos.ribeiro@gmail.com
License¶
This project is licensed under the MIT License - see the LICENSE file for details.
Citation¶
If you use this library in your research: