I have a short question. I am implementing Scikit-Learn in Typescript and currently blocked at understanding & implementing imputer (mean and regression strategies).
Based on the example given on Scikit-Learn page, http://scikit-learn.org/stable/modules/preprocessing.html#imputation
>>> import numpy as np
>>> from sklearn.preprocessing import Imputer
>>> imp = Imputer(missing_values='NaN', strategy='mean', axis=0)
>>> imp.fit([[1, 2], [np.nan, 3], [7, 6]])
Imputer(axis=0, copy=True, missing_values='NaN', strategy='mean', verbose=0)
>>> X = [[np.nan, 2], [6, np.nan], [7, 6]]
>>> print(imp.transform(X))
[[ 4. 2. ]
[ 6. 3.666...]
[ 7. 6. ]]
How does imputation against np.nan
in [[np.nan, 2], [6, np.nan], [7, 6]]
work?
- Could you please explain it to me how it works? I would appreciate any equations and background knowledge that I need to understand this.