50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
|
import pandas as pd
|
||
|
import numpy as np
|
||
|
from tensorflow import keras
|
||
|
import matplotlib.pyplot as plt
|
||
|
from sklearn.metrics import accuracy_score, f1_score
|
||
|
|
||
|
|
||
|
learned_model = 'model'
|
||
|
model = keras.models.load_model(learned_model)
|
||
|
|
||
|
train=pd.read_csv('train.csv', header=None, skiprows=1)
|
||
|
indexNames = train[train[1] ==2].index
|
||
|
train.drop(indexNames, inplace=True)
|
||
|
cols=[0,2,3]
|
||
|
X=train[cols].to_numpy()
|
||
|
y=train[1].to_numpy()
|
||
|
X=np.asarray(X).astype('float32')
|
||
|
|
||
|
test=pd.read_csv('test.csv', header=None, skiprows=1)
|
||
|
cols=[0,2,3]
|
||
|
indexNames = test[test[1] ==2].index
|
||
|
test.drop(indexNames, inplace=True)
|
||
|
X_test=test[cols].to_numpy()
|
||
|
y_test=test[1].to_numpy()
|
||
|
X_test=np.asarray(X_test).astype('float32')
|
||
|
|
||
|
predictions = model.predict(X_test)
|
||
|
|
||
|
|
||
|
acc = accuracy_score(y_test, predictions)
|
||
|
print('Accuracy: ', acc)
|
||
|
|
||
|
f1=f1_score(y_test, predictions)
|
||
|
print('F1: ', f1)
|
||
|
|
||
|
with open('evaluation.txt', 'a') as f:
|
||
|
f.write(str(acc) + "\n")
|
||
|
|
||
|
with open('evaluation.txt', 'r') as f:
|
||
|
lines = f.readlines()
|
||
|
|
||
|
|
||
|
fig = plt.figure(figsize=(5,5))
|
||
|
chart = fig.add_subplot()
|
||
|
chart.set_ylabel("Accuracy")
|
||
|
chart.set_xlabel("Build")
|
||
|
x = np.arange(0, len(lines), 1)
|
||
|
y = [float(x) for x in lines]
|
||
|
plt.plot(x, y, "go")
|
||
|
plt.savefig("evaluation.png")
|