# Machine Learning: Missing Data in Dataset and Imputer [duplicate]

I am a newbie in ML, and I am learning how to fill missing data in a dataset using Imputer. These are the few lines of code that I came across

from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values = 'NaN', strategy = 'mean', axis = 0)
imputer = imputer.fit(X[:, 1:3])
X[:, 1:3] = imputer.transform(X[:, 1:3])


Now I am not able to understand what is the role of the fit and the transform function. It will be great if someone can help. Thank you.

• I have seen it already but it was not clear to me, so I asked again – Turing101 Apr 16 '20 at 21:07