正如标题所说,我使用fit_transform
与CountVectorizer
训练数据..然后我使用tranform
仅与测试数据... ...将这个给了我一样使用fit
只在训练和tranform
只对测试数据?
The answer is YES :
fit_transform
is equivalent to fit
followed by transform
, but more efficiently implemented. See documentation
Both fit
and fit_transform
fit your classifier to your dataset. You can then use the same classifier to transform any other dataset (in your case the test set).
If you use fit
only on the training and transform
on the test data, you won't get the correct result.
When using fit_transform
on the training data, it means that the machine is learning from the parameters in the feature space and also transforming (scaling) the training data. On the other hand, you should only use transform
on the test data to scale it according to the parameters learned from the training data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.