第一种方式:
output_file = open('E:/XD_transfer/代码/CNN_new/try.csv', 'w')
output_file.write('Sample,'+ '\n')
for j in range(5):
output_file.write(str(j)+ '\n')
第二种方式:
output_df = pd.DataFrame({'Prob0': prob[:, 0], 'Prob1': prob[:, 1], 'Label': y_test, 'Predlabel': y_pred})
output_df.to_csv('E:/XD_transfer/代码/RF/label.csv', index=False)