Issue
This is code for feature scaling in which i am using fit_transform()
and transform()
:
##Feature scaling
from sklearn.preprocessing import StandardScaler
sc_x=StandardScaler()
X_train=sc_x.fit_transform(X_train)
X_test=sc_x.transform(X_test)
Solution
fit
means to fit the pre-processor to the data being provided. This is where the pre-processor "learns" from the data.
transform
means to transform the data (produce outputs) according to the fitted pre-processor; it is normally used on the test data, and unseen data in general (e.g. in new data that come after deploying a model).
fit_transform
means to do both - Fit the pre-processor to the data, then transform the data according to the fitted pre-processor. Calling fit_transform
is a convenience to avoid needing to call fit
and transform
sequentially on the same input, but of course this is only applicable to the training data (calling again fit_transform
in test or unseen data is unfortunately a common rookie mistake).
Answered By - bogatron
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.