Hardik
Hardik

Reputation: 31

How do I export the machine learning (Tensorflow) predictions to a csv file?

I have included my code here on google docs.

I am not able to export the predicted values which are printed as output to a csv file.

for i in range(0, 101):
prediction_run = sess.run(prediction, feed_dict={x: X[i].reshape(1, 60)})
accuracy_run = sess.run(accuracy, feed_dict={x: X[i].reshape(1, 60), y_: Y[i].reshape(1, 2)})
print("Original Class : ", y1[i], " Predicted Values : ", prediction_run[0], " Accuracy : ", accuracy_run)

Upvotes: 2

Views: 1512

Answers (1)

Dat Tran
Dat Tran

Reputation: 2392

Looking at your code you're not using pandas at all to export it to csv. What you can do is to do this:

import pandas as pd

prediction_value = sess.run(prediction, feed_dict={x: x_test}
prediction_df = pd.DataFrame(prediction_value)
prediction_df.to_csv('prediction.csv')

Btw, next time it would be better to put your code on gist instead in a google drive.

Upvotes: 2

Related Questions