IUM_08
This commit is contained in:
parent
b06db2db4b
commit
9d66acbdad
14
PMProject.yaml
Normal file
14
PMProject.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: OrangeQualityModel
|
||||||
|
|
||||||
|
conda_env: conda.yaml
|
||||||
|
|
||||||
|
entry_points:
|
||||||
|
train:
|
||||||
|
parameters:
|
||||||
|
epochs: {type: int, default: 100}
|
||||||
|
command: "python model.py"
|
||||||
|
|
||||||
|
test:
|
||||||
|
parameters:
|
||||||
|
model_path: {type: str, default: "orange_quality_model_tf.h5"}
|
||||||
|
command: "python test_model.py --model_path {model_path}"
|
10
conda.yaml
Normal file
10
conda.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
name: orange_quality_model_env
|
||||||
|
channels:
|
||||||
|
- defaults
|
||||||
|
dependencies:
|
||||||
|
- python=3.8
|
||||||
|
- pip
|
||||||
|
- pandas
|
||||||
|
- scikit-learn
|
||||||
|
- tensorflow
|
||||||
|
- mlflow
|
21
model.py
21
model.py
@ -3,6 +3,9 @@ import pandas as pd
|
|||||||
from sklearn.preprocessing import LabelEncoder, StandardScaler
|
from sklearn.preprocessing import LabelEncoder, StandardScaler
|
||||||
from sklearn.model_selection import train_test_split
|
from sklearn.model_selection import train_test_split
|
||||||
import json
|
import json
|
||||||
|
import mlflow
|
||||||
|
|
||||||
|
mlflow.set_tracking_uri("http://localhost:5000") # Ustawienie adresu MLflow Tracking Server
|
||||||
|
|
||||||
df = pd.read_csv('OrangeQualityData.csv')
|
df = pd.read_csv('OrangeQualityData.csv')
|
||||||
|
|
||||||
@ -30,11 +33,19 @@ model = tf.keras.Sequential([
|
|||||||
|
|
||||||
model.compile(optimizer='sgd', loss='mse')
|
model.compile(optimizer='sgd', loss='mse')
|
||||||
|
|
||||||
history = model.fit(X_train_scaled, y_train, epochs=100, verbose=0, validation_data=(X_test_scaled, y_test))
|
with mlflow.start_run():
|
||||||
|
mlflow.log_param("optimizer", 'sgd')
|
||||||
|
mlflow.log_param("loss_function", 'mse')
|
||||||
|
mlflow.log_param("epochs", 100)
|
||||||
|
|
||||||
model.save('orange_quality_model_tf.h5')
|
history = model.fit(X_train_scaled, y_train, epochs=100, verbose=0, validation_data=(X_test_scaled, y_test))
|
||||||
|
|
||||||
predictions = model.predict(X_test_scaled)
|
for key, value in history.history.items():
|
||||||
|
mlflow.log_metric(key, value[-1]) # Logujemy ostatnią wartość metryki
|
||||||
|
|
||||||
with open('predictions_tf.json', 'w') as f:
|
model.save('orange_quality_model_tf.h5')
|
||||||
json.dump(predictions.tolist(), f, indent=4)
|
|
||||||
|
predictions = model.predict(X_test_scaled)
|
||||||
|
|
||||||
|
with open('predictions_tf.json', 'w') as f:
|
||||||
|
json.dump(predictions.tolist(), f, indent=4)
|
||||||
|
Loading…
Reference in New Issue
Block a user