IUM_06
This commit is contained in:
parent
a6be9a7295
commit
ee4c1adab2
60
Jenkinsfile
vendored
60
Jenkinsfile
vendored
@ -1,54 +1,56 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent {
|
||||||
|
dockerfile true
|
||||||
|
}
|
||||||
|
|
||||||
|
triggers {
|
||||||
|
upstream(upstreamProjects: 's464913-training/training', threshold: hudson.model.Result.SUCCESS)
|
||||||
|
}
|
||||||
|
|
||||||
parameters {
|
parameters {
|
||||||
string (
|
buildSelector(
|
||||||
defaultValue: 'vskyper',
|
defaultSelector: lastSuccessful(),
|
||||||
description: 'Kaggle username',
|
description: 'Which build to use for copying artifacts',
|
||||||
name: 'KAGGLE_USERNAME',
|
name: 'BUILD_SELECTOR'
|
||||||
trim: false
|
|
||||||
)
|
|
||||||
password (
|
|
||||||
defaultValue: '',
|
|
||||||
description: 'Kaggle API key',
|
|
||||||
name: 'KAGGLE_KEY',
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Clone Repository') {
|
stage('Clone Repository') {
|
||||||
steps {
|
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 {
|
steps {
|
||||||
withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}", "KAGGLE_KEY=${params.KAGGLE_KEY}"]) {
|
copyArtifacts filter: 'data/*', projectName: 'z-s464913-create-dataset', selector: buildParameter('BUILD_SELECTOR')
|
||||||
sh 'pip install kaggle'
|
|
||||||
sh 'kaggle datasets download -d mlg-ulb/creditcardfraud'
|
|
||||||
sh 'unzip -o creditcardfraud.zip'
|
|
||||||
sh 'rm creditcardfraud.zip'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Run create-dataset script') {
|
|
||||||
agent {
|
|
||||||
dockerfile {
|
|
||||||
reuseNode true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Copy Artifacts from training job') {
|
||||||
steps {
|
steps {
|
||||||
sh 'chmod +x create-dataset.py'
|
copyArtifacts filter: 'model/*', projectName: 's464913-training/training', selector: buildParameter('BUILD_SELECTOR')
|
||||||
sh 'python3 ./create-dataset.py'
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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') {
|
stage('Archive Artifacts') {
|
||||||
steps {
|
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():
|
def main():
|
||||||
model = load_model("model/model.keras")
|
model = load_model("model/model.keras")
|
||||||
X_test = pd.read_csv("data/X_test.csv")
|
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 = model.predict(X_test)
|
||||||
y_pred = y_pred >= 0.5
|
y_pred = y_pred >= 0.5
|
||||||
np.savetxt("data/y_pred.csv", y_pred, delimiter=",")
|
|
||||||
|
|
||||||
cm = confusion_matrix(y_test, y_pred)
|
os.makedirs("evaluation", exist_ok=True)
|
||||||
print(
|
os.system("rm -rf evaluation/*")
|
||||||
"Recall metric in the testing dataset: ",
|
np.savetxt("evaluation/y_pred.csv", y_pred, delimiter=",")
|
||||||
cm[1, 1] / (cm[1, 0] + cm[1, 1]),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user