Skip to main content

Matrix completion and feature imputation algorithms

Project description

Build Status Coverage Status DOI

fancyimpute

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

Usage

from fancyimpute import BiScaler, KNN, NuclearNormMinimization, SoftImpute

# 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 features
X_filled_knn = KNN(k=3).complete(X_incomplete)

# matrix completion using convex optimization to find low-rank solution
# that still matches observed values. Slow!
X_filled_nnm = NuclearNormMinimization().complete(X_incomplete)

# Instead of solving the nuclear norm objective directly, instead
# induce sparsity using singular value thresholding
X_filled_softimpute = SoftImpute().complete(X_incomplete_normalized)

# print mean squared error for the three imputation methods above
nnm_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)

Algorithms

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fancyimpute-0.0.16.tar.gz (30.1 kB view details)

Uploaded Source

File details

Details for the file fancyimpute-0.0.16.tar.gz.

File metadata

File hashes

Hashes for fancyimpute-0.0.16.tar.gz
Algorithm Hash digest
SHA256 568928147560a7ed0e46447a0e0dddec94d24c4e818057a06888cee3541daa0d
MD5 90e49d2d32f5486ed1198144768adf6e
BLAKE2b-256 f2b99b52d0865be7435a2785864a0f2f13c8d437b766216e4a5be32a58fa69a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page