When scale the data, why the train dataset use 'fit' and 'transform', but the test dataset only use 'transform'?

后端 未结 7 1928
悲&欢浪女
悲&欢浪女 2021-02-01 03:32

When scale the data, why the train dataset use \'fit\' and \'transform\', but the test dataset only use \'transform\'?

SAMPLE_COUNT = 5000
TEST_COUNT = 20000
see         


        
7条回答
  •  孤独总比滥情好
    2021-02-01 04:07

    fit() is used to compute the parameter needed for transformation and transform() is for scaling the data to convert into standard format for the model.

    fit_tranform() is combination of two which is doing above work in efficiently.

    Since fit_transform() is already computing and transforming the training data only transformation for testing data is left,since parameter needed for transformation is already computed and stored only transformation() of testing data is left therefor only transform() is used instead of fit_transform().

提交回复
热议问题