Multibranch pipeline training
This commit is contained in:
parent
50d2dad25d
commit
55a736d0ce
@ -9,11 +9,11 @@ RUN python3 -m pip install --upgrade tensorflow
|
|||||||
|
|
||||||
WORKDIR app
|
WORKDIR app
|
||||||
|
|
||||||
ARG CUTOFF
|
ARG EPOCHS
|
||||||
ENV CUTOFF=${CUTOFF}
|
ENV EPOCHS=${EPOCHS}
|
||||||
|
|
||||||
COPY ml_training.py ./
|
COPY ml_training.py ./
|
||||||
COPY heart_2020_cleaned.csv ./
|
COPY heart_2020_cleaned.csv ./
|
||||||
|
|
||||||
|
|
||||||
CMD ["python3", "./ml_training.py"]
|
CMD ["python3", "./ml_training.py", EPOCHS]
|
||||||
|
27
Jenkinsfile.train
Normal file
27
Jenkinsfile.train
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
dockerfile true
|
||||||
|
}
|
||||||
|
parameters {
|
||||||
|
string(
|
||||||
|
defaultValue: "10",
|
||||||
|
description: 'How many epochs during training?',
|
||||||
|
name: 'epochs'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage("Git clone") {
|
||||||
|
steps {
|
||||||
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 's444465', url: 'https://git.wmi.amu.edu.pl/s444465/ium_444465']]])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("Training") {
|
||||||
|
steps {
|
||||||
|
withEnv(["EPOCHS=${params.EPOCHS}"]) {
|
||||||
|
sh "chmod 777 ml_training.py"
|
||||||
|
sh "python3 ml_training.py $EPOCHS"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,9 +3,13 @@ import pandas as pd
|
|||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
from sklearn.model_selection import train_test_split
|
from sklearn.model_selection import train_test_split
|
||||||
from sklearn.preprocessing import StandardScaler
|
from sklearn.preprocessing import StandardScaler
|
||||||
|
import sys
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
no_of_epochs = 10
|
||||||
|
if len(sys.argv) == 2:
|
||||||
|
no_of_epochs = int(sys.argv[1])
|
||||||
|
|
||||||
scaler = StandardScaler()
|
scaler = StandardScaler()
|
||||||
feature_names = ["BMI", "SleepTime", "Sex", "Diabetic", "PhysicalActivity", "Smoking", "AlcoholDrinking"]
|
feature_names = ["BMI", "SleepTime", "Sex", "Diabetic", "PhysicalActivity", "Smoking", "AlcoholDrinking"]
|
||||||
|
|
||||||
@ -54,7 +58,7 @@ def main():
|
|||||||
test_X = tf.convert_to_tensor(test_X)
|
test_X = tf.convert_to_tensor(test_X)
|
||||||
test_Y = tf.convert_to_tensor(test_Y)
|
test_Y = tf.convert_to_tensor(test_Y)
|
||||||
|
|
||||||
model.fit(train_X, train_Y, epochs=10)
|
model.fit(train_X, train_Y, epochs=no_of_epochs)
|
||||||
model.save("trained_model")
|
model.save("trained_model")
|
||||||
|
|
||||||
test_loss, test_acc, test_rec = model.evaluate(test_X, test_Y, verbose=1)
|
test_loss, test_acc, test_rec = model.evaluate(test_X, test_Y, verbose=1)
|
||||||
|
Loading…
Reference in New Issue
Block a user