Added evaluation

This commit is contained in:
Dawid 2021-05-10 21:11:07 +02:00
parent d566b3869a
commit 15065514a9
2 changed files with 62 additions and 0 deletions

41
Jenkinsfile_evaluation Normal file
View File

@ -0,0 +1,41 @@
pipeline {
agent {dockerfile true}
parameters {
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'BUILD_SELECTOR'
)
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'WHICH_BUILD_TRAIN'
)
}
stages {
stage('copyArtifacts') {
steps {
copyArtifacts fingerprintArtifacts: true, projectName: 's434804-create-dataset', selector: buildParameter('BUILD_SELECTOR')
copyArtifacts fingerprintArtifacts: true, projectName: 's434804-training/master', selector: buildParameter('WHICH_BUILD_TRAIN')
}
}
stage('evaluation') {
steps {
sh 'chmod +x tensor-eval.py'
sh 'python3 "tensor-eval.py" >> evaluation.txt'
}
}
stage('archiveArtifacts') {
steps{
archiveArtifacts 'evaluation.txt'
}
}
stage('sendMail') {
steps{
emailext body: currentBuild.result ?: 'EVALUATION SUCCESS',
subject: 's434804',
to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms'
}
}
}
}

21
tensor-eval.py Normal file
View File

@ -0,0 +1,21 @@
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error as rmse
reg = LinearRegression()
alldata = pd.read_csv(
'country_vaccinations.csv', header=0, skipinitialspace=True,
usecols=['total_vaccinations', 'people_vaccinated', 'daily_vaccinations' ,'daily_vaccinations_per_million']).dropna()
X = alldata[[c for c in alldata.columns if c != 'daily_vaccinations']]
y = alldata['daily_vaccinations']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 6)
lin_reg = reg.fit(X_train, y_train)
score = lin_reg.score(X_test, y_test)
prediction = lin_reg.predict(X_test)
print("RMSE:", rmse(y_test, prediction, squared=False))
print("Score:", score)