I'm a python newbie and I am having a problem with csv module.
My code creates the csv file sucessfully but the csv file remains empty.
Here is my code:
with open('log.csv', 'w') as stream:
csvwriter = csv.writer(stream, delimiter=',', quotechar='"')
for i in range(0, 200):
model.train(input_fn=train_input_fn, steps=100)
evaluation_result = model.evaluate(input_fn=test_input_fn)
predictions = list(model.predict(input_fn=test_input_fn))
prediction_result = betting.test_betting_stategy(predictions, test_features, test_labels)
csvwriter.writerow([(i + 1) * 100, evaluation_result['accuracy'], evaluation_result['average_loss'], prediction_result['performance']])
stream.close()
My question is how do I get python to flush to disk and write the csv file?