-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
23 lines (17 loc) · 840 Bytes
/
test.py
File metadata and controls
23 lines (17 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import keras
import pandas as pd
import numpy as np
from sklearn.preprocessing import LabelBinarizer
from sklearn.metrics import accuracy_score, precision_score, recall_score
dataToTest = pd.read_csv('./data/sign_mnist_test/sign_mnist_test.csv')
test_labels = dataToTest['label']
dataToTest.drop('label', axis=1, inplace=True)
test_images = dataToTest.values
label_binrizer = LabelBinarizer()
test_labels = label_binrizer.fit_transform(test_labels)
test_images = test_images.reshape(test_images.shape[0], 28, 28, 1)
model = keras.models.load_model('./model.keras')
y_pred = model.predict(test_images)
print("Accuracy: ", accuracy_score(test_labels, y_pred.round()))
print("Precision: ", precision_score(test_labels, y_pred.round(), average='weighted'))
print("Recall: ", recall_score(test_labels, y_pred.round(), average='weighted'))