【发布时间】:2021-12-19 16:17:10
【问题描述】:
我正在使用 Rendom Forest 进行预测
from sklearn.ensemble import RandomForestClassifier
forest_clf = RandomForestClassifier(random_state=42)
y_train_pred = cross_val_predict(forest_clf, X_train, y_train, cv=3)
对于 y_train_pred 系统显示 95% 的精度
我使用相同的模型进行实际预测
test_stocks = test_set.drop("is4PercPrft", axis=1)
test_stocks_labels = test_set["is4PercPrft"].copy()
test_prepared = full_pipeline.transform(test_stocks)
test_stocks_labels = test_stocks_labels.astype(np.uint8)
test_stocks_labels.value_counts()
对于下面的行,我收到错误
final_predictions = forest_clf.predict(test_prepared)
This RandomForestClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this estimator.
【问题讨论】:
-
我没有看到你在任何地方都适合这个模型。
标签: python scikit-learn