Package: fancyimpute
A variety of matrix completion and imputation algorithms implemented in Python 3.6.To install:pip install fancyimputeIf you run intotensorflowproblems and use anaconda, you can try to fix them withconda install cudatoolkit.Important Caveats(1) This project is in "bare maintenance" mode. That means we are not planning on adding more imputation algorithms or features (but might if we get inspired). Please do report bugs, and we'll try to fix them. Also, we are happy to take pull requests for more algorithms and/or features.(2)IterativeImputerstarted its life as afancyimputeoriginal, but was then merged intoscikit-learnand we deleted it fromfancyimputein favor of the better-testedsklearnversion. As a convenience, you can stillfrom fancyimpute import IterativeImputer, but under the hood it's just doingfrom sklearn.impute import IterativeImputer.  That means if you updatescikit-learnin the future, you may also change the behavior ofIterativeImputer.UsagefromfancyimputeimportKNN,NuclearNormMinimization,SoftImpute,BiScaler# X is the complete data matrix# X_incomplete has the same values as X except a subset have been replace with NaN# Use 3 nearest rows which have a feature to fill in each row's missing featuresX_filled_knn=KNN(k=3).fit_transform(X_incomplete)# matrix completion using convex optimization to find low-rank solution# that still matches observed values. Slow!X_filled_nnm=NuclearNormMinimization().fit_transform(X_incomplete)# Instead of solving the nuclear norm objective directly, instead# induce sparsity using singular value thresholdingX_incomplete_normalized=BiScaler().fit_transform(X_incomplete)X_filled_softimpute=SoftImpute().fit_transform(X_incomplete_normalized)# print mean squared error for the  imputation methods abovennm_mse=((X_filled_nnm[missing_mask]-X[missing_mask])**2).mean()print("Nuclear norm minimization MSE:%f"%nnm_mse)softImpute_mse=((X_filled_softimpute[missing_mask]-X[missing_mask])**2).mean()print("SoftImpute MSE:%f"%softImpute_mse)knn_mse=((X_filled_knn[missing_mask]-X[missing_mask])**2).mean()print("knnImpute MSE:%f"%knn_mse)AlgorithmsSimpleFill: Replaces missing entries with the mean or median of each column.KNN: Nearest neighbor imputations which weights samples using the mean squared difference
on features for which two rows both have observed data.SoftImpute: Matrix completion by iterative soft thresholding of SVD decompositions. Inspired by thesoftImputepackage for R, which is based onSpectral Regularization Algorithms for Learning Large Incomplete Matricesby Mazumder et. al.IterativeImputer: A strategy for imputing missing values by modeling each feature with missing values as a function of other features in a round-robin fashion. A stub that links toscikit-learn'sIterativeImputer.IterativeSVD: Matrix completion by iterative low-rank SVD decomposition. Should be similar to SVDimpute fromMissing value estimation methods for DNA microarraysby Troyanskaya et. al.MatrixFactorization: Direct factorization of the incomplete matrix into low-rankUandV, with per-row and per-column biases, as well as a global bias. Solved by SGD in pure numpy.NuclearNormMinimization: Simple implementation ofExact Matrix Completion via Convex Optimizationby Emmanuel Candes and Benjamin Recht usingcvxpy. Too slow for large matrices.BiScaler: Iterative estimation of row/column means and standard deviations to get doubly normalized
matrix. Not guaranteed to converge but works well in practice. Taken fromMatrix Completion and Low-Rank SVD via Fast Alternating Least Squares.CitationIf you usefancyimputein your academic publication, please cite it as follows:@software{fancyimpute,author={Alex Rubinsteyn and Sergey Feldman},title={fancyimpute: An Imputation Library for Python},url={https://github.com/iskandr/fancyimpute},version={0.7.0},date={2016},}