scikit-learn/scikit-learn — pull request #2148 by NicolasTr (2013-07-10 16:33:32+00:00)
Title: Missing values imputation

Here's some code for the data imputation.

It's still a work in progress so *Travis* will probably be mad at me.

I'll work on the documentation tomorrow. Meanwhile, you can look at the tests if you want to see how it works.

***What's new***
I added four classes:
* MeanImputer: replace the missing values with the mean of the row/column
* MedianImputer: replace the missing values with the median of the row/column
* MostFrequentImputer: replace the missing values with the most frequent value in the row/column
* RandomImputer: replace the missing values with one of the values of the row/column

***Behaviour***
* Any value can represent a missing value (not only np.nan for dense matrices and 0 for sparse matrices, *any* value)
* Different missing values can be imputed separately in a pipeline
* Support dense and sparse matrices
* **To determine:** What should the imputer do if he has nothing to work with? For example: What should be done if there's no median value because the whole row/column is missing?
* 0 for the mean and np.nan for the median/most frequent/random?
* always np.nan?
* Let the user choose with a parameter?

***What's missing***
- [ ] **Documentation**
- [ ] Add np.nan support in input (it's actually a problem here because the `àrray2d`and `atleast2d_or_csc` functions check if all the elements of the array are finite)
- [ ] Improve dense format support in MostFrequentImputer (mostly support of masked array)
- [ ] Add sparse format support to MostFrequentImputer (exclusion of the missing values and handling of the 0's without the use of a dense intermediate)
- [ ] Add dense format support to RandomImputer (mostly support of masked array)
- [ ] Add sparse format support to RandomImputer (exclusion of the missing values and handling of the 0's without the use of a dense intermediate)
- [ ] Add tests with copy