1

I have following code, I am not able to understand the difference between use of fit_transform() and transform() method in this case.

In the following code, when I am using fit_transform(X_valid) instead of transform(X_valid) it gives me different outputs.

from sklearn.impute import SimpleImputer

# Imputation
my_imputer = SimpleImputer()
imputed_X_train = pd.DataFrame(my_imputer.fit_transform(X_train))
imputed_X_valid = pd.DataFrame(my_imputer.transform(X_valid))
Dipen Gajjar
  • 113
  • 5
  • 1
    [a](https://scikit-learn.org/stable/modules/generated/sklearn.impute.SimpleImputer.html) and [b](https://datascience.stackexchange.com/questions/12321/difference-between-fit-and-fit-transform-in-scikit-learn-models) should help you to understand. – akhetos Jan 14 '20 at 16:26
  • 1
    You can refer this question https://datascience.stackexchange.com/questions/12321/difference-between-fit-and-fit-transform-in-scikit-learn-models – Aman Raparia Jan 14 '20 at 17:49

0 Answers0