Skip to main content

Matrix completion and feature imputation algorithms

Project description

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

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.5.tar.gz (22.4 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: fancyimpute-0.0.5.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fancyimpute-0.0.5.tar.gz
Algorithm Hash digest
SHA256 5dc9c049628fec659c327d5d3f102a7d160e09c30bd34c27cf40d60d43f4b4df
MD5 ba1c95a26b2da94e87d30e952d849023
BLAKE2b-256 6e1937cd986aa683918663331e0ab2685eb488defff68bc525c5a344b28f8bf3

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