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 = KNN(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.6.tar.gz (28.4 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for fancyimpute-0.0.6.tar.gz
Algorithm Hash digest
SHA256 91a575c0c9c9b3a3008352f495c62b0f99d7681b90fe67ac9b80202641356f0d
MD5 6c156924d9d777f988eee5b9e4080bb9
BLAKE2b-256 b53df0da9eac69a5a1b3633586fdc989e08ce8ba6cd8245c4f5b4473a13abd20

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