mlflow
This commit is contained in:
parent
57def16f1a
commit
248ef29471
@ -1,7 +1,7 @@
|
|||||||
name: MLflow_s464937
|
name: MLflow_s464937
|
||||||
conda_env: conda.yaml
|
conda_env: conda.yaml
|
||||||
entry_points:
|
entry_points:
|
||||||
optimal_parameters:
|
main:
|
||||||
parameters:
|
parameters:
|
||||||
epochs: { type: int, default: 20 }
|
epochs: { type: int, default: 20 }
|
||||||
command: 'python mlflow_model.py {epochs}'
|
command: 'python mlflow_model.py {epochs}'
|
@ -7,6 +7,8 @@ from sklearn.pipeline import Pipeline
|
|||||||
from tensorflow.keras.models import Sequential
|
from tensorflow.keras.models import Sequential
|
||||||
from tensorflow.keras.layers import Dense
|
from tensorflow.keras.layers import Dense
|
||||||
import tensorflow as tf
|
import tensorflow as tf
|
||||||
|
from sklearn.metrics import accuracy_score, precision_recall_fscore_support, mean_squared_error
|
||||||
|
from math import sqrt
|
||||||
import mlflow
|
import mlflow
|
||||||
|
|
||||||
|
|
||||||
@ -14,17 +16,16 @@ mlflow.set_tracking_uri("http://localhost:5000")
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
data = pd.read_csv('./data/train.csv')
|
data = pd.read_csv('../openpowerlifting.csv')
|
||||||
|
|
||||||
data = data[['Sex', 'Age', 'BodyweightKg', 'TotalKg']].dropna()
|
data = data[['Sex', 'Age', 'BodyweightKg', 'TotalKg']].dropna()
|
||||||
data['Age'] = pd.to_numeric(data['Age'], errors='coerce')
|
data['Age'] = pd.to_numeric(data['Age'], errors='coerce')
|
||||||
data['BodyweightKg'] = pd.to_numeric(data['BodyweightKg'], errors='coerce')
|
data['BodyweightKg'] = pd.to_numeric(data['BodyweightKg'], errors='coerce')
|
||||||
data['TotalKg'] = pd.to_numeric(data['TotalKg'], errors='coerce')
|
data['TotalKg'] = pd.to_numeric(data['TotalKg'], errors='coerce')
|
||||||
features = data[['Sex', 'Age', 'BodyweightKg']]
|
features = data[['Sex', 'Age', 'BodyweightKg']]
|
||||||
target = data['TotalKg']
|
target = data['TotalKg']
|
||||||
|
|
||||||
X_train, X_test, y_train, y_test = train_test_split(features, target, test_size=0.2, random_state=42)
|
X_train, X_test, y_train, y_test = train_test_split(features, target, test_size=0.2, random_state=42)
|
||||||
|
|
||||||
|
with mlflow.start_run() as run:
|
||||||
preprocessor = ColumnTransformer(
|
preprocessor = ColumnTransformer(
|
||||||
transformers=[
|
transformers=[
|
||||||
('num', StandardScaler(), ['Age', 'BodyweightKg']),
|
('num', StandardScaler(), ['Age', 'BodyweightKg']),
|
||||||
@ -32,23 +33,46 @@ def main():
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
pipeline = Pipeline(steps=[
|
model = Sequential([
|
||||||
('preprocessor', preprocessor),
|
|
||||||
('model', Sequential([
|
|
||||||
Dense(64, activation='relu', input_dim=5),
|
Dense(64, activation='relu', input_dim=5),
|
||||||
Dense(64, activation='relu'),
|
Dense(64, activation='relu'),
|
||||||
Dense(1)
|
Dense(1)
|
||||||
]))
|
|
||||||
])
|
])
|
||||||
|
|
||||||
pipeline['model'].compile(optimizer='adam', loss='mse', metrics=['mae'])
|
model.compile(optimizer='adam', loss='mse', metrics=['mae'])
|
||||||
|
pipeline = Pipeline(steps=[
|
||||||
|
('preprocessor', preprocessor),
|
||||||
|
('model', model)
|
||||||
|
])
|
||||||
|
|
||||||
X_train_excluded = X_train.iloc[1:]
|
X_train_excluded = X_train.iloc[1:]
|
||||||
y_train_excluded = y_train.iloc[1:]
|
y_train_excluded = y_train.iloc[1:]
|
||||||
|
|
||||||
pipeline.fit(X_train_excluded, y_train_excluded, model__epochs=int(sys.argv[1]), model__validation_split=0.1)
|
pipeline.fit(X_train_excluded, y_train_excluded, model__epochs=int(sys.argv[1]), model__validation_split=0.1)
|
||||||
|
|
||||||
pipeline['model'].save('powerlifting_model.h5')
|
pipeline['model'].save('powerlifting_model.h5')
|
||||||
|
loaded_model = tf.keras.models.load_model('powerlifting_model.h5')
|
||||||
|
|
||||||
|
test_data = pd.read_csv('openpowerlifting.csv')
|
||||||
|
test_data = test_data[['Sex', 'Age', 'BodyweightKg', 'TotalKg']].dropna()
|
||||||
|
test_data['Age'] = pd.to_numeric(test_data['Age'], errors='coerce')
|
||||||
|
test_data['BodyweightKg'] = pd.to_numeric(test_data['BodyweightKg'], errors='coerce')
|
||||||
|
test_data['TotalKg'] = pd.to_numeric(test_data['TotalKg'], errors='coerce')
|
||||||
|
test_features = test_data[['Sex', 'Age', 'BodyweightKg']]
|
||||||
|
test_target = test_data['TotalKg']
|
||||||
|
|
||||||
|
X_test_transformed = preprocessor.transform(test_features)
|
||||||
|
predictions = loaded_model.predict(X_test_transformed)
|
||||||
|
predictions_df = pd.DataFrame(predictions, columns=['predicted_TotalKg'])
|
||||||
|
predictions_df['actual_TotalKg'] = test_target.reset_index(drop=True)
|
||||||
|
predictions_df.to_csv('powerlifting_test_predictions.csv', index=False)
|
||||||
|
|
||||||
|
data = pd.read_csv('powerlifting_test_predictions.csv')
|
||||||
|
y_pred = data['predicted_TotalKg']
|
||||||
|
y_test = data['actual_TotalKg']
|
||||||
|
rmse = sqrt(mean_squared_error(y_test, y_pred))
|
||||||
|
|
||||||
|
|
||||||
|
mlflow.log_param("epochs", int(sys.argv[1]))
|
||||||
|
mlflow.log_metric("rmse", rmse)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
6
mlflow/mlruns/0/meta.yaml
Normal file
6
mlflow/mlruns/0/meta.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
artifact_location: mlflow-artifacts:/0
|
||||||
|
creation_time: 1716052613528
|
||||||
|
experiment_id: '0'
|
||||||
|
last_update_time: 1716052613528
|
||||||
|
lifecycle_stage: active
|
||||||
|
name: Default
|
15
mlruns/0/852a00be19a04756b19b2a0fdb0c6a83/meta.yaml
Normal file
15
mlruns/0/852a00be19a04756b19b2a0fdb0c6a83/meta.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
artifact_uri: mlflow-artifacts:/0/852a00be19a04756b19b2a0fdb0c6a83/artifacts
|
||||||
|
end_time: null
|
||||||
|
entry_point_name: ''
|
||||||
|
experiment_id: '0'
|
||||||
|
lifecycle_stage: active
|
||||||
|
run_id: 852a00be19a04756b19b2a0fdb0c6a83
|
||||||
|
run_name: skillful-worm-708
|
||||||
|
run_uuid: 852a00be19a04756b19b2a0fdb0c6a83
|
||||||
|
source_name: ''
|
||||||
|
source_type: 4
|
||||||
|
source_version: ''
|
||||||
|
start_time: 1716053034879
|
||||||
|
status: 1
|
||||||
|
tags: []
|
||||||
|
user_id: szymonbartanowicz
|
1
mlruns/0/852a00be19a04756b19b2a0fdb0c6a83/params/epoches
Normal file
1
mlruns/0/852a00be19a04756b19b2a0fdb0c6a83/params/epoches
Normal file
@ -0,0 +1 @@
|
|||||||
|
12
|
1
mlruns/0/852a00be19a04756b19b2a0fdb0c6a83/params/epochs
Normal file
1
mlruns/0/852a00be19a04756b19b2a0fdb0c6a83/params/epochs
Normal file
@ -0,0 +1 @@
|
|||||||
|
20
|
@ -0,0 +1 @@
|
|||||||
|
https://git.wmi.amu.edu.pl/s464937/ium_464937.git
|
@ -0,0 +1 @@
|
|||||||
|
main
|
@ -0,0 +1 @@
|
|||||||
|
conda
|
@ -0,0 +1 @@
|
|||||||
|
skillful-worm-708
|
@ -0,0 +1 @@
|
|||||||
|
57def16f1aff244cfe1e2bc1042a97b64459753e
|
@ -0,0 +1 @@
|
|||||||
|
https://git.wmi.amu.edu.pl/s464937/ium_464937.git
|
@ -0,0 +1 @@
|
|||||||
|
file:///Users/szymonbartanowicz/studia/mag_1/inzynieria_uczenia_maszynowego/ium_464937#mlflow
|
@ -0,0 +1 @@
|
|||||||
|
PROJECT
|
@ -0,0 +1 @@
|
|||||||
|
szymonbartanowicz
|
15
mlruns/0/a7bad8d56b5a476193134123f3175c00/meta.yaml
Normal file
15
mlruns/0/a7bad8d56b5a476193134123f3175c00/meta.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
artifact_uri: mlflow-artifacts:/0/a7bad8d56b5a476193134123f3175c00/artifacts
|
||||||
|
end_time: 1716053941729
|
||||||
|
entry_point_name: ''
|
||||||
|
experiment_id: '0'
|
||||||
|
lifecycle_stage: active
|
||||||
|
run_id: a7bad8d56b5a476193134123f3175c00
|
||||||
|
run_name: brawny-stag-513
|
||||||
|
run_uuid: a7bad8d56b5a476193134123f3175c00
|
||||||
|
source_name: ''
|
||||||
|
source_type: 4
|
||||||
|
source_version: ''
|
||||||
|
start_time: 1716053939145
|
||||||
|
status: 4
|
||||||
|
tags: []
|
||||||
|
user_id: szymonbartanowicz
|
1
mlruns/0/a7bad8d56b5a476193134123f3175c00/params/epoches
Normal file
1
mlruns/0/a7bad8d56b5a476193134123f3175c00/params/epoches
Normal file
@ -0,0 +1 @@
|
|||||||
|
12
|
1
mlruns/0/a7bad8d56b5a476193134123f3175c00/params/epochs
Normal file
1
mlruns/0/a7bad8d56b5a476193134123f3175c00/params/epochs
Normal file
@ -0,0 +1 @@
|
|||||||
|
20
|
@ -0,0 +1 @@
|
|||||||
|
https://git.wmi.amu.edu.pl/s464937/ium_464937.git
|
@ -0,0 +1 @@
|
|||||||
|
local
|
@ -0,0 +1 @@
|
|||||||
|
main
|
@ -0,0 +1 @@
|
|||||||
|
conda
|
@ -0,0 +1 @@
|
|||||||
|
brawny-stag-513
|
@ -0,0 +1 @@
|
|||||||
|
57def16f1aff244cfe1e2bc1042a97b64459753e
|
@ -0,0 +1 @@
|
|||||||
|
https://git.wmi.amu.edu.pl/s464937/ium_464937.git
|
@ -0,0 +1 @@
|
|||||||
|
file:///Users/szymonbartanowicz/studia/mag_1/inzynieria_uczenia_maszynowego/ium_464937#mlflow
|
@ -0,0 +1 @@
|
|||||||
|
PROJECT
|
@ -0,0 +1 @@
|
|||||||
|
szymonbartanowicz
|
15
mlruns/0/b7c7e490ed0f4a6d98293d275b5f67a9/meta.yaml
Normal file
15
mlruns/0/b7c7e490ed0f4a6d98293d275b5f67a9/meta.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
artifact_uri: mlflow-artifacts:/0/b7c7e490ed0f4a6d98293d275b5f67a9/artifacts
|
||||||
|
end_time: 1716053969998
|
||||||
|
entry_point_name: ''
|
||||||
|
experiment_id: '0'
|
||||||
|
lifecycle_stage: active
|
||||||
|
run_id: b7c7e490ed0f4a6d98293d275b5f67a9
|
||||||
|
run_name: zealous-crow-502
|
||||||
|
run_uuid: b7c7e490ed0f4a6d98293d275b5f67a9
|
||||||
|
source_name: ''
|
||||||
|
source_type: 4
|
||||||
|
source_version: ''
|
||||||
|
start_time: 1716053967858
|
||||||
|
status: 4
|
||||||
|
tags: []
|
||||||
|
user_id: szymonbartanowicz
|
1
mlruns/0/b7c7e490ed0f4a6d98293d275b5f67a9/params/epochs
Normal file
1
mlruns/0/b7c7e490ed0f4a6d98293d275b5f67a9/params/epochs
Normal file
@ -0,0 +1 @@
|
|||||||
|
12
|
@ -0,0 +1 @@
|
|||||||
|
https://git.wmi.amu.edu.pl/s464937/ium_464937.git
|
@ -0,0 +1 @@
|
|||||||
|
local
|
@ -0,0 +1 @@
|
|||||||
|
main
|
@ -0,0 +1 @@
|
|||||||
|
conda
|
@ -0,0 +1 @@
|
|||||||
|
zealous-crow-502
|
@ -0,0 +1 @@
|
|||||||
|
57def16f1aff244cfe1e2bc1042a97b64459753e
|
@ -0,0 +1 @@
|
|||||||
|
https://git.wmi.amu.edu.pl/s464937/ium_464937.git
|
@ -0,0 +1 @@
|
|||||||
|
file:///Users/szymonbartanowicz/studia/mag_1/inzynieria_uczenia_maszynowego/ium_464937#mlflow
|
@ -0,0 +1 @@
|
|||||||
|
PROJECT
|
@ -0,0 +1 @@
|
|||||||
|
szymonbartanowicz
|
15
mlruns/0/dd9e039328564f8bb20449bd7bea8ab1/meta.yaml
Normal file
15
mlruns/0/dd9e039328564f8bb20449bd7bea8ab1/meta.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
artifact_uri: mlflow-artifacts:/0/dd9e039328564f8bb20449bd7bea8ab1/artifacts
|
||||||
|
end_time: 1716053927316
|
||||||
|
entry_point_name: ''
|
||||||
|
experiment_id: '0'
|
||||||
|
lifecycle_stage: active
|
||||||
|
run_id: dd9e039328564f8bb20449bd7bea8ab1
|
||||||
|
run_name: efficient-cod-832
|
||||||
|
run_uuid: dd9e039328564f8bb20449bd7bea8ab1
|
||||||
|
source_name: ''
|
||||||
|
source_type: 4
|
||||||
|
source_version: ''
|
||||||
|
start_time: 1716053923906
|
||||||
|
status: 4
|
||||||
|
tags: []
|
||||||
|
user_id: szymonbartanowicz
|
1
mlruns/0/dd9e039328564f8bb20449bd7bea8ab1/params/epoches
Normal file
1
mlruns/0/dd9e039328564f8bb20449bd7bea8ab1/params/epoches
Normal file
@ -0,0 +1 @@
|
|||||||
|
12
|
1
mlruns/0/dd9e039328564f8bb20449bd7bea8ab1/params/epochs
Normal file
1
mlruns/0/dd9e039328564f8bb20449bd7bea8ab1/params/epochs
Normal file
@ -0,0 +1 @@
|
|||||||
|
20
|
@ -0,0 +1 @@
|
|||||||
|
https://git.wmi.amu.edu.pl/s464937/ium_464937.git
|
@ -0,0 +1 @@
|
|||||||
|
local
|
@ -0,0 +1 @@
|
|||||||
|
main
|
@ -0,0 +1 @@
|
|||||||
|
conda
|
@ -0,0 +1 @@
|
|||||||
|
efficient-cod-832
|
@ -0,0 +1 @@
|
|||||||
|
57def16f1aff244cfe1e2bc1042a97b64459753e
|
@ -0,0 +1 @@
|
|||||||
|
https://git.wmi.amu.edu.pl/s464937/ium_464937.git
|
@ -0,0 +1 @@
|
|||||||
|
file:///Users/szymonbartanowicz/studia/mag_1/inzynieria_uczenia_maszynowego/ium_464937#mlflow
|
@ -0,0 +1 @@
|
|||||||
|
PROJECT
|
@ -0,0 +1 @@
|
|||||||
|
szymonbartanowicz
|
Loading…
Reference in New Issue
Block a user