diff --git a/pytorch-example-evaluate.py b/pytorch-example-evaluate.py index fb68af5..7db5957 100644 --- a/pytorch-example-evaluate.py +++ b/pytorch-example-evaluate.py @@ -1,3 +1,4 @@ +from numpy.lib.function_base import average from sklearn.model_selection import train_test_split import torch import torch.nn as nn @@ -7,6 +8,8 @@ import torch.nn.functional as F from torch.utils.data import DataLoader, TensorDataset, random_split from sklearn import preprocessing from sklearn.metrics import accuracy_score +from sklearn.metrics import f1_score +from sklearn.metrics import mean_squared_error import sys class LogisticRegressionModel(torch.nn.Module): @@ -43,6 +46,10 @@ output_dim = 1 model = LogisticRegressionModel(input_dim, output_dim) pred = model(fTest) -accuracy = accuracy_score(fTest, np.argmax(pred.detach(), axis = 1)) +accuracy = accuracy_score(tTest, np.argmax(pred.detach().numpy(), axis = 1)) +f1 = f1_score(tTest, np.argmax(pred.detach().numpy(), axis = 1, average = None)) +rmse = mean_squared_error(tTest, np.argmax(pred.detach().numpy())) -print(f'Accuracy: {accuracy}') \ No newline at end of file +print(f'Accuracy: {accuracy}') +print(f'F1: {f1_score}') +print(f'RMSE: {rmse}') \ No newline at end of file