add eval script
Some checks failed
s440058-evaluation/pipeline/head There was a failure building this commit

This commit is contained in:
piotr6789 2021-05-24 13:08:51 +02:00
parent 2dd722ba58
commit 0df7d2d8cf

View File

@ -1,3 +1,4 @@
from numpy.lib.function_base import average
from sklearn.model_selection import train_test_split from sklearn.model_selection import train_test_split
import torch import torch
import torch.nn as nn 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 torch.utils.data import DataLoader, TensorDataset, random_split
from sklearn import preprocessing from sklearn import preprocessing
from sklearn.metrics import accuracy_score from sklearn.metrics import accuracy_score
from sklearn.metrics import f1_score
from sklearn.metrics import mean_squared_error
import sys import sys
class LogisticRegressionModel(torch.nn.Module): class LogisticRegressionModel(torch.nn.Module):
@ -43,6 +46,10 @@ output_dim = 1
model = LogisticRegressionModel(input_dim, output_dim) model = LogisticRegressionModel(input_dim, output_dim)
pred = model(fTest) 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}') print(f'Accuracy: {accuracy}')
print(f'F1: {f1_score}')
print(f'RMSE: {rmse}')