add eval script
Some checks failed
s440058-evaluation/pipeline/head There was a failure building this commit
Some checks failed
s440058-evaluation/pipeline/head There was a failure building this commit
This commit is contained in:
parent
2b3bfc70e4
commit
d76512c266
39
lab06/jenkinsfile-evaluate
Normal file
39
lab06/jenkinsfile-evaluate
Normal file
@ -0,0 +1,39 @@
|
||||
pipeline {
|
||||
agent {
|
||||
dockerfile true
|
||||
}
|
||||
parameters{
|
||||
buildSelector(
|
||||
defaultSelector: lastSuccessful(),
|
||||
description: 'Which build to use for copying artifacts',
|
||||
name: 'WHICH_BUILD'
|
||||
)
|
||||
}
|
||||
stages {
|
||||
stage('checkout') {
|
||||
steps {
|
||||
copyArtifacts fingerprintArtifacts: true, projectName: 's440058-create-dataset', selector: buildParameter('WHICH_BUILD')
|
||||
}
|
||||
}
|
||||
stage('Docker'){
|
||||
steps{
|
||||
sh 'python3 "./pytorch-example-evaluate.py" > eval-acc-result.txt'
|
||||
}
|
||||
}
|
||||
stage('archiveArtifacts') {
|
||||
steps{
|
||||
archiveArtifacts 'eval-acc-result.txt'
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
success {
|
||||
mail body: 'SUCCESS TRAINING', subject: 's440058', to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms'
|
||||
}
|
||||
|
||||
failure {
|
||||
mail body: 'FAILURE TRAINING', subject: 's440058', to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
47
pytorch-example-evaluate.py
Normal file
47
pytorch-example-evaluate.py
Normal file
@ -0,0 +1,47 @@
|
||||
from sklearn.model_selection import train_test_split
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import torch.nn.functional as F
|
||||
from torch.utils.data import DataLoader, TensorDataset, random_split
|
||||
from sklearn import preprocessing
|
||||
import sys
|
||||
|
||||
class LogisticRegressionModel(torch.nn.Module):
|
||||
def __init__(self, input_dim, output_dim):
|
||||
super(LogisticRegressionModel, self).__init__()
|
||||
self.linear = nn.Linear(input_dim, output_dim)
|
||||
self.sigmoid = nn.Sigmoid()
|
||||
def forward(self, x):
|
||||
out = self.linear(x)
|
||||
return self.sigmoid(out)
|
||||
|
||||
results = pd.read_csv('diabetes2.csv')
|
||||
|
||||
results.dropna()
|
||||
|
||||
data_train, data_valid, data_test = np.split(results.sample(frac=1), [int(.6*len(results)), int(.8*len(results))])
|
||||
columns_to_train = ['Glucose', 'BloodPressure', 'Insulin', 'Age']
|
||||
|
||||
x_train = data_train[columns_to_train].astype(np.float32)
|
||||
y_train = data_train['Outcome'].astype(np.float32)
|
||||
|
||||
x_test = data_test[columns_to_train].astype(np.float32)
|
||||
y_test = data_test['Outcome'].astype(np.float32)
|
||||
|
||||
fTrain = torch.from_numpy(x_train.values)
|
||||
tTrain = torch.from_numpy(y_train.values.reshape(460,1))
|
||||
|
||||
fTest= torch.from_numpy(x_test.values)
|
||||
tTest = torch.from_numpy(y_test.values)
|
||||
|
||||
input_dim = 4
|
||||
output_dim = 1
|
||||
|
||||
model = LogisticRegressionModel(input_dim, output_dim)
|
||||
|
||||
pred = model(xTest)
|
||||
accuracy = accuracy_score(fTest, np.argmax(pred.detach(), axis = 1))
|
||||
|
||||
print(f'Accuracy: {accuracy}')
|
Loading…
Reference in New Issue
Block a user