final_valid_predictions = pd.DataFrame.from_dict(final_valid_predictions, orient="index").reset_index() final_valid_predictions.columns = ['Id', 'class_0', 'class_1'] final_valid_predictions.to_csv(r"oof.csv", index=False) test_dict = {} test_dict.update(dict(zip(test.Id.values.tolist(), test_preds))) submission = pd.DataFrame.from_dict(test_dict, orient="index").reset_index() submission.columns = ['Id', 'class_0', 'class_1'] submission.to_csv(r"submission.csv", index=False) submission
时间: 2024-04-08 09:32:10 浏览: 159
f-teain.rar_Data mining_large data matlab_predictions
这段代码将验证集和测试集的预测结果保存到csv文件中。首先,将final_valid_predictions转换为DataFrame格式,并设置列名为'Id', 'class_0', 'class_1',然后将其保存为名为'oof.csv'的文件。接着,将test_dict转换为DataFrame格式,并设置列名为'Id', 'class_0', 'class_1',最后将其保存为名为'submission.csv'的文件。submission是保存了测试集预测结果的DataFrame。你可以将submission输出来查看结果。
阅读全文