IUM_06
This commit is contained in:
parent
a6be9a7295
commit
ee4c1adab2
60
Jenkinsfile
vendored
60
Jenkinsfile
vendored
@ -1,54 +1,56 @@
|
||||
pipeline {
|
||||
agent any
|
||||
agent {
|
||||
dockerfile true
|
||||
}
|
||||
|
||||
triggers {
|
||||
upstream(upstreamProjects: 's464913-training/training', threshold: hudson.model.Result.SUCCESS)
|
||||
}
|
||||
|
||||
parameters {
|
||||
string (
|
||||
defaultValue: 'vskyper',
|
||||
description: 'Kaggle username',
|
||||
name: 'KAGGLE_USERNAME',
|
||||
trim: false
|
||||
)
|
||||
password (
|
||||
defaultValue: '',
|
||||
description: 'Kaggle API key',
|
||||
name: 'KAGGLE_KEY',
|
||||
buildSelector(
|
||||
defaultSelector: lastSuccessful(),
|
||||
description: 'Which build to use for copying artifacts',
|
||||
name: 'BUILD_SELECTOR'
|
||||
)
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Clone Repository') {
|
||||
steps {
|
||||
git branch: 'main', url: 'https://git.wmi.amu.edu.pl/s464913/ium_464913.git'
|
||||
git branch: 'evaluation', url: 'https://git.wmi.amu.edu.pl/s464913/ium_464913.git'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Download dataset') {
|
||||
stage('Copy Artifacts from dataset job') {
|
||||
steps {
|
||||
withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}", "KAGGLE_KEY=${params.KAGGLE_KEY}"]) {
|
||||
sh 'pip install kaggle'
|
||||
sh 'kaggle datasets download -d mlg-ulb/creditcardfraud'
|
||||
sh 'unzip -o creditcardfraud.zip'
|
||||
sh 'rm creditcardfraud.zip'
|
||||
}
|
||||
copyArtifacts filter: 'data/*', projectName: 'z-s464913-create-dataset', selector: buildParameter('BUILD_SELECTOR')
|
||||
}
|
||||
}
|
||||
|
||||
stage('Run create-dataset script') {
|
||||
agent {
|
||||
dockerfile {
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
|
||||
stage('Copy Artifacts from training job') {
|
||||
steps {
|
||||
sh 'chmod +x create-dataset.py'
|
||||
sh 'python3 ./create-dataset.py'
|
||||
copyArtifacts filter: 'model/*', projectName: 's464913-training/training', selector: buildParameter('BUILD_SELECTOR')
|
||||
}
|
||||
}
|
||||
|
||||
stage('Run predict script') {
|
||||
steps {
|
||||
sh 'chmod +x predict.py'
|
||||
sh 'python3 ./predict.py'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Run metrics script') {
|
||||
steps {
|
||||
sh 'chmod +x metrics.py'
|
||||
sh 'python3 ./metrics.py'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Archive Artifacts') {
|
||||
steps {
|
||||
archiveArtifacts artifacts: 'data/*', onlyIfSuccessful: true
|
||||
archiveArtifacts artifacts: 'evaluation/*', onlyIfSuccessful: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
27
metrics.py
Normal file
27
metrics.py
Normal file
@ -0,0 +1,27 @@
|
||||
from sklearn.metrics import (
|
||||
accuracy_score,
|
||||
precision_score,
|
||||
recall_score,
|
||||
f1_score,
|
||||
mean_squared_error,
|
||||
)
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def main():
|
||||
y_test = pd.read_csv("data/y_test.csv")
|
||||
y_pred = pd.read_csv("evaluation/y_pred.csv")
|
||||
|
||||
accuracy = accuracy_score(y_test, y_pred)
|
||||
precision_micro = precision_score(y_test, y_pred, average="micro")
|
||||
recall_micro = recall_score(y_test, y_pred, average="micro")
|
||||
|
||||
with open(r"evaluation/metrics.txt", "a") as f:
|
||||
f.write(f"Accuracy: {accuracy}\n")
|
||||
f.write(f"Micro-average Precision: {precision_micro}\n")
|
||||
f.write(f"Micro-average Recall: {recall_micro}\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
10
predict.py
10
predict.py
@ -11,17 +11,13 @@ import numpy as np
|
||||
def main():
|
||||
model = load_model("model/model.keras")
|
||||
X_test = pd.read_csv("data/X_test.csv")
|
||||
y_test = pd.read_csv("data/y_test.csv")
|
||||
|
||||
y_pred = model.predict(X_test)
|
||||
y_pred = y_pred >= 0.5
|
||||
np.savetxt("data/y_pred.csv", y_pred, delimiter=",")
|
||||
|
||||
cm = confusion_matrix(y_test, y_pred)
|
||||
print(
|
||||
"Recall metric in the testing dataset: ",
|
||||
cm[1, 1] / (cm[1, 0] + cm[1, 1]),
|
||||
)
|
||||
os.makedirs("evaluation", exist_ok=True)
|
||||
os.system("rm -rf evaluation/*")
|
||||
np.savetxt("evaluation/y_pred.csv", y_pred, delimiter=",")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user