The transform() and fit_transform() difference

vxecqmjhc report abuse

What is the difference between the “transform” and “fit_transform” methods in scikit-learn? In which situations should I use each one? Their descriptions are pretty similar.


mat_lo7 report abuse

You need to call fit() first before transform() otherwise it wouldn’t work.

HPaduB report abuse

The fit_transform() method is the same as apply fit() and then transform() methods sequentially. It’s convenient when applied to the train set. After you get your results with the train set you want to apply standardization as well to the test set or to new values from which you want to get prediction. And this must be done with the same mean and standard deviation values. The fit() method saves these values obtained from the train set as internal state. And after that you can apply the transform() method to any other data, and it will be transformed with previously saved parameters.

Add Answer

Need support?

Just drop us an email to ... Show more