From aa46dae73102f479143f37e535dd93e051278e1b Mon Sep 17 00:00:00 2001 From: Dominik Strzako Date: Thu, 13 May 2021 19:18:15 +0200 Subject: [PATCH] Zadanie 6 --- Jenkinsfile_train | 48 ++++++++++++++++++++++++++++++++++++++++++ Zadanie_06_training.py | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 Jenkinsfile_train create mode 100644 Zadanie_06_training.py diff --git a/Jenkinsfile_train b/Jenkinsfile_train new file mode 100644 index 0000000..d4c63df --- /dev/null +++ b/Jenkinsfile_train @@ -0,0 +1,48 @@ +pipeline { + agent {dockerfile true} + parameters { + buildSelector( + defaultSelector: lastSuccessful(), + description: 'Which build to use for copying artifacts', + name: 'BUILD_SELECTOR') + string( + defaultValue: '500', + description: 'Enter the number of Epochs', + name: 'epochs', + trim: false) + } + + stages { + stage('copyArtifacts') { + steps { + copyArtifacts fingerprintArtifacts: true, projectName: 's434788-create-dataset', selector: buildParameter('BUILD_SELECTOR') + sh 'python3 lab06_training.py ${epochs}' + } + } + + stage('Archive artifacts') { + steps{ + archiveArtifacts 'model_movies/**' + } + } + } + + post { + success { + + build job: 's430705-evaluation/master' + mail body: 'SUCCESS', + subject: 's430705', + to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms' + } + unstable { + mail body: 'UNSTABLE', subject: 's430705', to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms' + } + failure { + mail body: 'FAILURE', subject: 's430705', to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms' + } + changed { + mail body: 'CHANGED', subject: 's430705', to: '26ab8f35.uam.onmicrosoft.com@emea.teams.ms' + } + } +} \ No newline at end of file diff --git a/Zadanie_06_training.py b/Zadanie_06_training.py new file mode 100644 index 0000000..0c082c8 --- /dev/null +++ b/Zadanie_06_training.py @@ -0,0 +1,38 @@ +from tensorflow.keras.models import Sequential, load_model +from tensorflow.keras.layers import Dense +from sklearn.metrics import accuracy_score, classification_report +import pandas as pd +from sklearn.model_selection import train_test_split +import wget +import numpy as np +import os + +url = 'https://git.wmi.amu.edu.pl/s434788/ium_434788/raw/branch/master/winequality-red.csv' +wget.download(url, out='winequality-red.csv', bar=None) + +wine=pd.read_csv('winequality-red.csv') +wine + +y = wine.quality +y.head() + +x = wine.drop(['quality'], axis= 1) +x.head() + +x=((x-x.min())/(x.max()-x.min())) #Normalizacja + +x_train, x_test, y_train, y_test = train_test_split(x,y , test_size=0.2,train_size=0.8, random_state=21) + +def regression_model(): + model = Sequential() + model.add(Dense(32,activation = "relu", input_shape = (x_train.shape[1],))) + model.add(Dense(64,activation = "relu")) + model.add(Dense(1,activation = "relu")) + + model.compile(optimizer = "adam", loss = "mean_squared_error") + return model + +model = regression_model() +model.fit(x_train, y_train, epochs = 600, verbose = 1) + +model.save('wine_model') \ No newline at end of file