На этой странице https://www.kaggle.com/baghern/a-deep-dive-into-sklearn-pipelines
Он вызывает fit_transfrom
для преобразования данных следующим образом:
from sklearn.pipeline import FeatureUnion
feats = FeatureUnion([('text', text),
('length', length),
('words', words),
('words_not_stopword', words_not_stopword),
('avg_word_length', avg_word_length),
('commas', commas)])
feature_processing = Pipeline([('feats', feats)])
feature_processing.fit_transform(X_train)
Во время обучения с обработкой объектов используются только fit
, а затем predict
.
from sklearn.ensemble import RandomForestClassifier
pipeline = Pipeline([
('features',feats),
('classifier', RandomForestClassifier(random_state = 42)),
])
pipeline.fit(X_train, y_train)
preds = pipeline.predict(X_test)
np.mean(preds == y_test)
Вопрос в том, выполняет ли fit
преобразование X_train
(как то, что достигается с помощью transform
, поскольку мы не называем fit_transform
здесь) для второго случая?