add mlflow
This commit is contained in:
parent
aeaf3178a0
commit
a9a40b0424
@ -12,14 +12,19 @@ and prints a short summary of the dataset as well as its subsets.
|
|||||||
### Zadanie 2
|
### Zadanie 2
|
||||||
add Jenkinsfiles and mock data preprocessing
|
add Jenkinsfiles and mock data preprocessing
|
||||||
|
|
||||||
### Zadanie 5
|
### Zadanie 4
|
||||||
added lab4 file with new python script and updated Dockerfile.
|
added lab4 directory with new python script and updated Dockerfile.
|
||||||
The container downloads the dataset and installs software needed,
|
The container downloads the dataset and installs software needed,
|
||||||
then trains and evaluates model on the dataset.
|
then trains and evaluates model on the dataset.
|
||||||
Loss and accuracy are saved to test_eval.txt file.
|
Loss and accuracy are saved to test_eval.txt file.
|
||||||
|
|
||||||
|
### Zadanie 5
|
||||||
|
added lab5 directory with scripts
|
||||||
|
|
||||||
### Zadanie 6
|
### Zadanie 6
|
||||||
added create, train, eval directories in lab5
|
added create, train, eval directories in lab5
|
||||||
|
|
||||||
|
### Zadanie 7
|
||||||
|
updated contents of lab5/train directory
|
||||||
|
|
||||||
ium01.ipynb is a notebook used to develop previously mentioned scripts.
|
ium01.ipynb is a notebook used to develop previously mentioned scripts.
|
||||||
|
1
lab5/eval/Jenkinsfile
vendored
1
lab5/eval/Jenkinsfile
vendored
@ -55,6 +55,7 @@ pipeline {
|
|||||||
stage('archive artifact') {
|
stage('archive artifact') {
|
||||||
steps {
|
steps {
|
||||||
archiveArtifacts 'eval.csv'
|
archiveArtifacts 'eval.csv'
|
||||||
|
archiveArtifacts 'plot.png'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import csv
|
import csv
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import seaborn as sns
|
|
||||||
import sys
|
|
||||||
import tensorflow
|
|
||||||
from tensorflow.keras import layers
|
|
||||||
from tensorflow.keras.models import load_model
|
from tensorflow.keras.models import load_model
|
||||||
|
|
||||||
|
|
||||||
@ -20,3 +17,11 @@ with open('eval.csv', 'a', newline='') as fp:
|
|||||||
wr = csv.writer(fp, dialect='excel')
|
wr = csv.writer(fp, dialect='excel')
|
||||||
wr.writerow(results)
|
wr.writerow(results)
|
||||||
|
|
||||||
|
metrics = pd.read_csv('eval.csv', header=None, names=['loss', 'accuracy'])
|
||||||
|
|
||||||
|
fig = plt.figure()
|
||||||
|
plt.plot(metrics.accuracy)
|
||||||
|
plt.ylabel('Accuracy')
|
||||||
|
plt.xlabel('Build no.')
|
||||||
|
|
||||||
|
fig.savefig('plot.png')
|
||||||
|
8
lab5/train/MLproject
Normal file
8
lab5/train/MLproject
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
name: s470607
|
||||||
|
docker_env:
|
||||||
|
image: kubakonieczny/ium:train-sacred-mlflow
|
||||||
|
entry_points:
|
||||||
|
main:
|
||||||
|
parameters:
|
||||||
|
learning_rate: (type: float, default: 0.0003)
|
||||||
|
comment: "python3 train.py {learning_rate}"
|
@ -3,3 +3,4 @@ pandas
|
|||||||
tensorflow
|
tensorflow
|
||||||
keras==2.3.1
|
keras==2.3.1
|
||||||
sacred
|
sacred
|
||||||
|
mlflow
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import mlflow
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from sacred import Experiment
|
from sacred import Experiment
|
||||||
from sacred.observers import FileStorageObserver, MongoObserver
|
from sacred.observers import FileStorageObserver, MongoObserver
|
||||||
@ -19,34 +20,37 @@ def my_config():
|
|||||||
|
|
||||||
@ex.capture
|
@ex.capture
|
||||||
def prepare_train_model(learning_rate, _run):
|
def prepare_train_model(learning_rate, _run):
|
||||||
_run.info["prepare_model"] = str(datetime.now())
|
with mlflow.start_run():
|
||||||
|
_run.info["prepare_model"] = str(datetime.now())
|
||||||
|
|
||||||
X_train = pd.read_csv('train.csv')
|
X_train = pd.read_csv('train.csv')
|
||||||
X_valid = pd.read_csv('valid.csv')
|
X_valid = pd.read_csv('valid.csv')
|
||||||
|
|
||||||
Y_train = X_train.pop('stabf')
|
Y_train = X_train.pop('stabf')
|
||||||
Y_train = pd.get_dummies(Y_train)
|
Y_train = pd.get_dummies(Y_train)
|
||||||
|
|
||||||
Y_valid = X_valid.pop('stabf')
|
Y_valid = X_valid.pop('stabf')
|
||||||
Y_valid = pd.get_dummies(Y_valid)
|
Y_valid = pd.get_dummies(Y_valid)
|
||||||
|
|
||||||
model = tensorflow.keras.Sequential([
|
model = tensorflow.keras.Sequential([
|
||||||
layers.Input(shape=(12,)),
|
layers.Input(shape=(12,)),
|
||||||
layers.Dense(32),
|
layers.Dense(32),
|
||||||
layers.Dense(16),
|
layers.Dense(16),
|
||||||
layers.Dense(2, activation='softmax')
|
layers.Dense(2, activation='softmax')
|
||||||
])
|
])
|
||||||
|
|
||||||
model.compile(
|
model.compile(
|
||||||
loss=tensorflow.keras.losses.BinaryCrossentropy(),
|
loss=tensorflow.keras.losses.BinaryCrossentropy(),
|
||||||
optimizer=tensorflow.keras.optimizers.Adam(learning_rate=learning_rate),
|
optimizer=tensorflow.keras.optimizers.Adam(learning_rate=learning_rate),
|
||||||
metrics=[tensorflow.keras.metrics.BinaryAccuracy()])
|
metrics=[tensorflow.keras.metrics.BinaryAccuracy()])
|
||||||
|
|
||||||
history = model.fit(X_train, Y_train, epochs=2, validation_data=(X_valid, Y_valid))
|
history = model.fit(X_train, Y_train, epochs=2, validation_data=(X_valid, Y_valid))
|
||||||
|
|
||||||
model.save('grid-stability-dense.h5')
|
model.save('grid-stability-dense.h5')
|
||||||
|
|
||||||
_run.info['history'] = str(history.history['loss'][-1])
|
_run.info['history'] = str(history.history['loss'][-1])
|
||||||
|
mlflow.log_metric('loss', history.history['loss'][-1])
|
||||||
|
mlflow.log_param('learning_rate', learning_rate)
|
||||||
|
|
||||||
|
|
||||||
@ex.main
|
@ex.main
|
||||||
|
Loading…
Reference in New Issue
Block a user