Search code examples
pythonscikit-learnscale

Can we use .fit_transform() directly?


from sklearn.preprocessing import MinMaxScaler()
scaler = MinMaxScaler()

can I directly do:

scaled_data = scaler.fit_transform(mymatrix)

without doing scaler.fit(mymatrix) first?

If not, why so? What is the difference? Doesnt scaler.fit_transform() function already compute the variance and mean values too before transforming?


Solution

  • As you can see in the docs here you can, because fit_transform performs first a fit(), after that it applies a transform().