{"id":13713039,"url":"https://github.com/iskandr/fancyimpute","last_synced_at":"2025-05-14T18:07:11.208Z","repository":{"id":38185132,"uuid":"45646870","full_name":"iskandr/fancyimpute","owner":"iskandr","description":"Multivariate imputation and matrix completion algorithms implemented in Python","archived":false,"fork":false,"pushed_at":"2023-10-25T17:26:07.000Z","size":293,"stargazers_count":1267,"open_issues_count":2,"forks_count":179,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-13T12:46:22.591Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iskandr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-11-05T23:39:34.000Z","updated_at":"2025-04-10T22:20:03.000Z","dependencies_parsed_at":"2024-01-18T07:14:17.973Z","dependency_job_id":null,"html_url":"https://github.com/iskandr/fancyimpute","commit_stats":{"total_commits":185,"total_committers":12,"mean_commits":"15.416666666666666","dds":0.3675675675675676,"last_synced_commit":"36374f84b14a0e870049815bd0b2bc4792d697a1"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iskandr%2Ffancyimpute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iskandr%2Ffancyimpute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iskandr%2Ffancyimpute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iskandr%2Ffancyimpute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iskandr","download_url":"https://codeload.github.com/iskandr/fancyimpute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254198515,"owners_count":22030966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T23:01:26.414Z","updated_at":"2025-05-14T18:07:06.200Z","avatar_url":"https://github.com/iskandr.png","language":"Python","readme":"[![Build Status](https://travis-ci.org/iskandr/fancyimpute.svg?branch=master)](https://travis-ci.org/iskandr/fancyimpute) [![Coverage Status](https://coveralls.io/repos/github/iskandr/fancyimpute/badge.svg?branch=master)](https://coveralls.io/github/iskandr/fancyimpute?branch=master) [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.51773.svg)](http://dx.doi.org/10.5281/zenodo.51773)\n\n\n![plot](https://user-images.strikinglycdn.com/res/hrscywv4p/image/upload/c_limit,fl_lossy,h_1440,w_720,f_auto,q_auto/174108/654579_364680.png)\n\n\nA variety of matrix completion and imputation algorithms implemented in Python 3.6.\n\nTo install:\n\n`pip install fancyimpute`\n\nIf you run into `tensorflow` problems and use anaconda, you can try to fix them with `conda install cudatoolkit`. \n\n## Important Caveats\n\n(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. \n\n(2) `IterativeImputer` started its life as a `fancyimpute` original, but was then merged into `scikit-learn` and we deleted it from `fancyimpute` in favor of the better-tested `sklearn` version. As a convenience, you can still `from fancyimpute import IterativeImputer`, but under the hood it's just doing `from sklearn.impute import IterativeImputer`.  That means if you update `scikit-learn` in the future, you may also change the behavior of `IterativeImputer`. \n\n\n## Usage\n\n```python\nfrom fancyimpute import KNN, NuclearNormMinimization, SoftImpute, BiScaler\n\n# X is the complete data matrix\n# X_incomplete has the same values as X except a subset have been replace with NaN\n\n# Use 3 nearest rows which have a feature to fill in each row's missing features\nX_filled_knn = KNN(k=3).fit_transform(X_incomplete)\n\n# matrix completion using convex optimization to find low-rank solution\n# that still matches observed values. Slow!\nX_filled_nnm = NuclearNormMinimization().fit_transform(X_incomplete)\n\n# Instead of solving the nuclear norm objective directly, instead\n# induce sparsity using singular value thresholding\nX_incomplete_normalized = BiScaler().fit_transform(X_incomplete)\nX_filled_softimpute = SoftImpute().fit_transform(X_incomplete_normalized)\n\n# print mean squared error for the  imputation methods above\nnnm_mse = ((X_filled_nnm[missing_mask] - X[missing_mask]) ** 2).mean()\nprint(\"Nuclear norm minimization MSE: %f\" % nnm_mse)\n\nsoftImpute_mse = ((X_filled_softimpute[missing_mask] - X[missing_mask]) ** 2).mean()\nprint(\"SoftImpute MSE: %f\" % softImpute_mse)\n\nknn_mse = ((X_filled_knn[missing_mask] - X[missing_mask]) ** 2).mean()\nprint(\"knnImpute MSE: %f\" % knn_mse)\n```\n\n## Algorithms\n\n* `SimpleFill`: Replaces missing entries with the mean or median of each column.\n\n* `KNN`: Nearest neighbor imputations which weights samples using the mean squared difference\non features for which two rows both have observed data.\n\n* `SoftImpute`: Matrix completion by iterative soft thresholding of SVD decompositions. Inspired by the [softImpute](https://web.stanford.edu/~hastie/swData/softImpute/vignette.html) package for R, which is based on [Spectral Regularization Algorithms for Learning Large Incomplete Matrices](http://web.stanford.edu/~hastie/Papers/mazumder10a.pdf) by Mazumder et. al.\n\n* `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 to `scikit-learn`'s [IterativeImputer](https://scikit-learn.org/stable/modules/generated/sklearn.impute.IterativeImputer.html).\n\n* `IterativeSVD`: Matrix completion by iterative low-rank SVD decomposition. Should be similar to SVDimpute from [Missing value estimation methods for DNA microarrays](http://www.ncbi.nlm.nih.gov/pubmed/11395428) by Troyanskaya et. al.\n\n* `MatrixFactorization`: Direct factorization of the incomplete matrix into low-rank `U` and `V`, with per-row and per-column biases, as well as a global bias. Solved by SGD in pure numpy.\n\n* `NuclearNormMinimization`: Simple implementation of [Exact Matrix Completion via Convex Optimization](http://statweb.stanford.edu/~candes/papers/MatrixCompletion.pdf\n) by Emmanuel Candes and Benjamin Recht using [cvxpy](http://www.cvxpy.org). Too slow for large matrices.\n\n* `BiScaler`: Iterative estimation of row/column means and standard deviations to get doubly normalized\nmatrix. Not guaranteed to converge but works well in practice. Taken from [Matrix Completion and Low-Rank SVD via Fast Alternating Least Squares](http://arxiv.org/abs/1410.2596).\n\n## Citation\n\nIf you use `fancyimpute` in your academic publication, please cite it as follows:\n```bibtex\n@software{fancyimpute,\n  author = {Alex Rubinsteyn and Sergey Feldman},\n  title={fancyimpute: An Imputation Library for Python},\n  url = {https://github.com/iskandr/fancyimpute},\n  version = {0.7.0},\n  date = {2016},\n}\n```\n","funding_links":[],"categories":["Data Processing","Missing Data Methods","Sklearn实用程序","Feature Extraction"],"sub_categories":["Data Pre-processing \u0026 Loading","Commercial Software","General Feature Extraction"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiskandr%2Ffancyimpute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiskandr%2Ffancyimpute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiskandr%2Ffancyimpute/lists"}