My Code:
### Working with NaN using sklearn
import numpy as np
from sklearn.preprocessing import Imputer
### Mean strategy
imp = Imputer(missing_values='NaN', strategy='mean', axis=1)
imp.fit([1,5,9,np.NaN])
X = [1,5,9,np.NaN]
y = imp.transform(X)
print (y)
After running I am getting below warning message: C:\Users\Admin\Anaconda3\lib\site-packages\sklearn\utils\validation.py:386: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and willraise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample. DeprecationWarning)
How to solve it? I tried the reshape but it is giving error message saying: 'list' object has no attribute 'reshape'
Please help.
imp.fit([1,5,9,np.NaN])change toimp.fit(np.array([1,5,9,np.NaN]))andX = [1,5,9,np.NaN]should beX = np.array([1,5,9,np.NaN])not sure if you still need to reshape but the type at least will be compatible with sklearn - EdChum