plot
This commit is contained in:
parent
c785c6d147
commit
72f5852d1a
@ -3,7 +3,7 @@ import re
|
|||||||
from sklearn import metrics
|
from sklearn import metrics
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import csv
|
import csv
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
f = open("result.txt", "r")
|
f = open("result.txt", "r")
|
||||||
|
|
||||||
list_result, list_predicted=[],[]
|
list_result, list_predicted=[],[]
|
||||||
@ -27,3 +27,21 @@ print("RMSE: ",metrics[2])
|
|||||||
with open('eval.csv', 'a', newline='') as f:
|
with open('eval.csv', 'a', newline='') as f:
|
||||||
writer = csv.writer(f)
|
writer = csv.writer(f)
|
||||||
writer.writerow((metrics[0],metrics[1], metrics[2]))
|
writer.writerow((metrics[0],metrics[1], metrics[2]))
|
||||||
|
|
||||||
|
|
||||||
|
MAE,MSE,RMSE=[],[],[]
|
||||||
|
with open('eval.csv', 'r') as r:
|
||||||
|
for row in r:
|
||||||
|
# row variable is a list that represents a row in csv
|
||||||
|
row=row.split(',')
|
||||||
|
MAE.append(float(row[0]))
|
||||||
|
MSE.append(float(row[1]))
|
||||||
|
RMSE.append(float(row[2]))
|
||||||
|
|
||||||
|
|
||||||
|
plt.ylabel('F score')
|
||||||
|
plt.plot(np.arange(0, len(MAE)), MAE)
|
||||||
|
plt.plot(np.arange(0, len(MSE)), MSE)
|
||||||
|
plt.plot(np.arange(0, len(RMSE)), RMSE)
|
||||||
|
|
||||||
|
plt.savefig('metrics.png')
|
Loading…
Reference in New Issue
Block a user