我在 python 中工作pandas
(in a Jupyter
笔记本),我在其中为泰坦尼克号数据集创建了一个随机森林模型。https://www.kaggle.com/c/titanic/data
我读入测试和训练数据,然后清理它并添加新列(两者相同的列)。
在拟合和重新拟合模型并尝试增强等之后;我决定使用一种模型:
X2 = train_data[['Pclass','Sex','Age','richness']]
rfc_model_3 = RandomForestClassifier(n_estimators=200)
%time cross_val_score(rfc_model_3, X2, Y_target).mean()
rfc_model_3.fit(X2, Y_target)
然后我预测,是否有人幸存
X_test = test_data[['Pclass','Sex','Age','richness']]
predictions = rfc_model_3.predict(X_test)
preds = pd.DataFrame(predictions, columns=['Survived'])
有没有办法让我将预测添加为column
进入测试文件?