diff --git a/mlflow/MLproject b/mlflow/MLproject new file mode 100644 index 0000000..5706564 --- /dev/null +++ b/mlflow/MLproject @@ -0,0 +1,10 @@ +name: Credit card fraud MLFlow - s464913 + +conda_env: conda.yaml + +entry_points: + main: + parameters: + learning_rate: { type: float, default: 0.001 } + epochs: { type: int, default: 5 } + command: 'python mlflow_train_evaluation.py {learning_rate} {epochs}' diff --git a/mlflow/conda.yaml b/mlflow/conda.yaml new file mode 100644 index 0000000..d715f9e --- /dev/null +++ b/mlflow/conda.yaml @@ -0,0 +1,11 @@ +name: Credit card fraud MLFlow - s464913 +channels: + - defaults +dependencies: + - python=3.12 + - pip + - pip: + - mlflow + - tensorflow + - pandas + - scikit-learn diff --git a/mlflow/mlflow_train_evaluation.py b/mlflow/mlflow_train_evaluation.py new file mode 100644 index 0000000..338920d --- /dev/null +++ b/mlflow/mlflow_train_evaluation.py @@ -0,0 +1,82 @@ +import os + +os.environ["TF_ENABLE_ONEDNN_OPTS"] = "0" + +from keras.models import Sequential +from keras.layers import BatchNormalization, Dropout, Dense, Flatten, Conv1D +from keras.optimizers import Adam +import pandas as pd +import sys +import mlflow +from sklearn.metrics import confusion_matrix + +mlflow.set_tracking_uri("http://localhost:5000") + + +def main(): + X_train = pd.read_csv("../data/X_train.csv") + X_val = pd.read_csv("../data/X_val.csv") + y_train = pd.read_csv("../data/y_train.csv") + y_val = pd.read_csv("../data/y_val.csv") + + X_train = X_train.to_numpy() + X_val = X_val.to_numpy() + y_train = y_train.to_numpy() + y_val = y_val.to_numpy() + + X_train = X_train.reshape(X_train.shape[0], X_train.shape[1], 1) + X_val = X_val.reshape(X_val.shape[0], X_val.shape[1], 1) + + learning_rate = float(sys.argv[1]) + epochs = int(sys.argv[2]) + + with mlflow.start_run() as run: + print("MLflow run experiment_id: {0}".format(run.info.experiment_id)) + print("MLflow run artifact_uri: {0}".format(run.info.artifact_uri)) + + model = Sequential( + [ + Conv1D(32, 2, activation="relu", input_shape=X_train[0].shape), + BatchNormalization(), + Dropout(0.2), + Conv1D(64, 2, activation="relu"), + BatchNormalization(), + Dropout(0.5), + Flatten(), + Dense(64, activation="relu"), + Dropout(0.5), + Dense(1, activation="sigmoid"), + ] + ) + + model.compile( + optimizer=Adam(learning_rate=learning_rate), + loss="binary_crossentropy", + metrics=["accuracy"], + ) + + model.fit( + X_train, + y_train, + validation_data=(X_val, y_val), + epochs=epochs, + verbose=1, + ) + + mlflow.log_param("learning_rate", learning_rate) + mlflow.log_param("epochs", epochs) + + 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 + + cm = confusion_matrix(y_test, y_pred) + accuracy = cm[1, 1] / (cm[1, 0] + cm[1, 1]) + + mlflow.log_metric("accuracy", accuracy) + + +if __name__ == "__main__": + main() diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/meta.yaml b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/meta.yaml new file mode 100644 index 0000000..37df72a --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/meta.yaml @@ -0,0 +1,15 @@ +artifact_uri: mlflow-artifacts:/0/3c46f6c4b15743faa0119c4b9b804825/artifacts +end_time: 1715508788768 +entry_point_name: '' +experiment_id: '0' +lifecycle_stage: active +run_id: 3c46f6c4b15743faa0119c4b9b804825 +run_name: dapper-hog-137 +run_uuid: 3c46f6c4b15743faa0119c4b9b804825 +source_name: '' +source_type: 4 +source_version: '' +start_time: 1715508594003 +status: 3 +tags: [] +user_id: skype diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/metrics/accuracy b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/metrics/accuracy new file mode 100644 index 0000000..747fc03 --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/metrics/accuracy @@ -0,0 +1 @@ +1715508787882 0.8217821782178217 0 diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/params/epochs b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/params/epochs new file mode 100644 index 0000000..7813681 --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/params/epochs @@ -0,0 +1 @@ +5 \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/params/learning_rate b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/params/learning_rate new file mode 100644 index 0000000..eb5a1db --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/params/learning_rate @@ -0,0 +1 @@ +0.001 \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.gitRepoURL b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.gitRepoURL new file mode 100644 index 0000000..d953801 --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.gitRepoURL @@ -0,0 +1 @@ +https://git.wmi.amu.edu.pl/s464913/ium_464913.git \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.project.backend b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.project.backend new file mode 100644 index 0000000..c2c027f --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.project.backend @@ -0,0 +1 @@ +local \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.project.entryPoint b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.project.entryPoint new file mode 100644 index 0000000..88d050b --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.project.entryPoint @@ -0,0 +1 @@ +main \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.project.env b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.project.env new file mode 100644 index 0000000..f79e4cb --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.project.env @@ -0,0 +1 @@ +conda \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.runName b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.runName new file mode 100644 index 0000000..84230cd --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.runName @@ -0,0 +1 @@ +dapper-hog-137 \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.git.commit b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.git.commit new file mode 100644 index 0000000..2551700 --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.git.commit @@ -0,0 +1 @@ +a6be9a729562db8c47bc5fec88ad8f5216af0cf3 \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.git.repoURL b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.git.repoURL new file mode 100644 index 0000000..d953801 --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.git.repoURL @@ -0,0 +1 @@ +https://git.wmi.amu.edu.pl/s464913/ium_464913.git \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.name b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.name new file mode 100644 index 0000000..16c36b5 --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.name @@ -0,0 +1 @@ +file://C:\Users\skype\source\repos\Inżynieria Uczenia Maszynowego#\mlflow \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.type b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.type new file mode 100644 index 0000000..53f9167 --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.source.type @@ -0,0 +1 @@ +PROJECT \ No newline at end of file diff --git a/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.user b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.user new file mode 100644 index 0000000..872b62b --- /dev/null +++ b/mlflow/mlruns/0/3c46f6c4b15743faa0119c4b9b804825/tags/mlflow.user @@ -0,0 +1 @@ +skype \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/meta.yaml b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/meta.yaml new file mode 100644 index 0000000..0631b66 --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/meta.yaml @@ -0,0 +1,15 @@ +artifact_uri: mlflow-artifacts:/0/706dcf453a0842aaa48647e15521bb7b/artifacts +end_time: 1715508573447 +entry_point_name: '' +experiment_id: '0' +lifecycle_stage: active +run_id: 706dcf453a0842aaa48647e15521bb7b +run_name: loud-whale-40 +run_uuid: 706dcf453a0842aaa48647e15521bb7b +source_name: '' +source_type: 4 +source_version: '' +start_time: 1715508159092 +status: 3 +tags: [] +user_id: skype diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/metrics/accuracy b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/metrics/accuracy new file mode 100644 index 0000000..71ee3af --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/metrics/accuracy @@ -0,0 +1 @@ +1715508572612 0.7524752475247525 0 diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/params/epochs b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/params/epochs new file mode 100644 index 0000000..c793025 --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/params/epochs @@ -0,0 +1 @@ +7 \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/params/learning_rate b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/params/learning_rate new file mode 100644 index 0000000..eb5a1db --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/params/learning_rate @@ -0,0 +1 @@ +0.001 \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.gitRepoURL b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.gitRepoURL new file mode 100644 index 0000000..d953801 --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.gitRepoURL @@ -0,0 +1 @@ +https://git.wmi.amu.edu.pl/s464913/ium_464913.git \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.project.backend b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.project.backend new file mode 100644 index 0000000..c2c027f --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.project.backend @@ -0,0 +1 @@ +local \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.project.entryPoint b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.project.entryPoint new file mode 100644 index 0000000..88d050b --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.project.entryPoint @@ -0,0 +1 @@ +main \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.project.env b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.project.env new file mode 100644 index 0000000..f79e4cb --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.project.env @@ -0,0 +1 @@ +conda \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.runName b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.runName new file mode 100644 index 0000000..2fa0e0d --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.runName @@ -0,0 +1 @@ +loud-whale-40 \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.git.commit b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.git.commit new file mode 100644 index 0000000..2551700 --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.git.commit @@ -0,0 +1 @@ +a6be9a729562db8c47bc5fec88ad8f5216af0cf3 \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.git.repoURL b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.git.repoURL new file mode 100644 index 0000000..d953801 --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.git.repoURL @@ -0,0 +1 @@ +https://git.wmi.amu.edu.pl/s464913/ium_464913.git \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.name b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.name new file mode 100644 index 0000000..16c36b5 --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.name @@ -0,0 +1 @@ +file://C:\Users\skype\source\repos\Inżynieria Uczenia Maszynowego#\mlflow \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.type b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.type new file mode 100644 index 0000000..53f9167 --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.source.type @@ -0,0 +1 @@ +PROJECT \ No newline at end of file diff --git a/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.user b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.user new file mode 100644 index 0000000..872b62b --- /dev/null +++ b/mlflow/mlruns/0/706dcf453a0842aaa48647e15521bb7b/tags/mlflow.user @@ -0,0 +1 @@ +skype \ No newline at end of file diff --git a/mlflow/mlruns/0/meta.yaml b/mlflow/mlruns/0/meta.yaml new file mode 100644 index 0000000..7a5aa56 --- /dev/null +++ b/mlflow/mlruns/0/meta.yaml @@ -0,0 +1,6 @@ +artifact_location: mlflow-artifacts:/0 +creation_time: 1715508147231 +experiment_id: '0' +last_update_time: 1715508147231 +lifecycle_stage: active +name: Default