Skip to content

Multivariate imputation and matrix completion algorithms implemented in Python

License

Notifications You must be signed in to change notification settings

paulhendricks/fancyimpute

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fancyimpute

A variety of matrix completion and imputation algorithms implemented in Python.

Usage

from fancyimpute import (NuclearNormMinimization, BiScaler, DenseKNN)

biscaler = BiScaler()

# X is a data matrix which we're going to randomly drop entries from
missing_mask = np.random.randn(*X.shape) > 0
X_incomplete = X.copy()
# missing entries indicated with NaN
X_incomplete[missing_mask] = np.nan

# rescale both rows and columns to have zero mean and unit variance
X_incomplete_normalized = biscaler.fit_transform(X_incomplete)

# use 3 nearest rows which have a feature to fill in each row's missing features
knn_solver = DenseKNN(k=3)
X_filled_normalized = knn_solver.complete(X_incomplete)
X_filled = biscaler.inverse_transform(X_knn_normalized)

mse = ((X_filled[missing_mask] - X[missing_mask]) ** 2).mean()
print("MSE of reconstruction: %f" % mse)

Algorithms

About

Multivariate imputation and matrix completion algorithms implemented in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%