IUM_06 - update evaluation/Jenkinsfile, update predict.py - metrics plot
This commit is contained in:
parent
697e0ad2df
commit
f3f6ab7dee
2
evaluation/Jenkinsfile
vendored
2
evaluation/Jenkinsfile
vendored
@ -34,7 +34,7 @@ pipeline {
|
||||
steps {
|
||||
sh "chmod +x ./predict.py"
|
||||
sh "python3 ./predict.py"
|
||||
archiveArtifacts artifacts: 'predictions.csv, metrics.csv', onlyIfSuccessful: true
|
||||
archiveArtifacts artifacts: 'predictions.csv, metrics.csv, metrics.png', onlyIfSuccessful: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
predict.py
17
predict.py
@ -5,6 +5,9 @@ import numpy as np
|
||||
|
||||
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import seaborn as sns
|
||||
|
||||
from NeuralNetwork import NeuralNetwork
|
||||
|
||||
# Load model if it exists
|
||||
@ -42,6 +45,18 @@ if os.path.exists('./models/model.pth'):
|
||||
pd.DataFrame([[accuracy, precision, recall, f1]], columns=['Accuracy', 'Precision', 'Recall', 'F1']).to_csv('metrics.csv', index=False)
|
||||
else:
|
||||
# without header
|
||||
pd.DataFrame([[accuracy, precision, recall, f1]], columns=['Accuracy', 'Precision', 'Recall', 'F1']).to_csv('metrics.csv', index=False, mode='a', header=False)
|
||||
metrics = pd.read_csv('metrics.csv')
|
||||
metrics = metrics._append({'Accuracy': accuracy, 'Precision': precision, 'Recall': recall, 'F1': f1}, ignore_index=True)
|
||||
metrics.to_csv('metrics.csv', index=False, mode='a', header=False)
|
||||
|
||||
# Plot metrics line chart
|
||||
sns.set(style='whitegrid')
|
||||
plt.figure(figsize=(8, 6))
|
||||
sns.lineplot(data=metrics)
|
||||
plt.title('Metrics history')
|
||||
plt.xlabel('History number')
|
||||
plt.ylabel('Value')
|
||||
plt.legend()
|
||||
plt.savefig('metrics.png')
|
||||
else:
|
||||
raise FileNotFoundError('Model not found')
|
||||
|
Loading…
Reference in New Issue
Block a user