Zaktualizuj 'predict.py'
This commit is contained in:
parent
cf6e265d7a
commit
0405205089
30
predict.py
30
predict.py
@ -4,7 +4,18 @@ import numpy as np
|
||||
import sklearn
|
||||
import sklearn.model_selection
|
||||
from tensorflow.keras.models import load_model
|
||||
from sklearn.metrics import accuracy_score, precision_score, f1_score
|
||||
from sklearn.metrics import mean_absolute_error, mean_squared_error
|
||||
|
||||
import mlflow
|
||||
|
||||
# Wskazujemy ścieżkę do folderu, gdzie zostaną zapisane wyniki MLflow
|
||||
mlflow.set_tracking_uri("file:/mlflow")
|
||||
|
||||
# Ustawiamy nazwę eksperymentu
|
||||
mlflow.set_experiment("nazwa eksperymentu")
|
||||
|
||||
feature_cols = ['year', 'mileage', 'vol_engine']
|
||||
|
||||
|
||||
feature_cols = ['year', 'mileage', 'vol_engine']
|
||||
|
||||
@ -19,16 +30,13 @@ results = pd.DataFrame({'id': test_data['id'], 'year': test_data['year'], 'milea
|
||||
results.to_csv('predictions.csv', index=False)
|
||||
|
||||
y_true = test_data['price']
|
||||
y_pred = y_pred = [round(p[0]) for p in predictions]
|
||||
y_pred = [round(p[0]) for p in predictions]
|
||||
|
||||
print(y_pred)
|
||||
print(y_true)
|
||||
|
||||
accuracy = accuracy_score(y_true, y_pred)
|
||||
precision = precision_score(y_true, y_pred, average='micro')
|
||||
f1 = f1_score(y_true, y_pred, average='micro')
|
||||
mae = mean_absolute_error(y_true, y_pred)
|
||||
mse = mean_squared_error(y_true, y_pred)
|
||||
rmse = np.sqrt(mse)
|
||||
|
||||
with open('metrics.txt', 'w') as f:
|
||||
f.write(f"Accuracy: {accuracy:.4f}\n")
|
||||
f.write(f"Micro-average Precision: {precision:.4f}\n")
|
||||
f.write(f"Micro-average F1-score: {f1:.4f}\n")
|
||||
f.write(f"MAE: {mae:.4f}\n")
|
||||
f.write(f"MSE: {mse:.4f}\n")
|
||||
f.write(f"RMSE: {rmse:.4f}\n")
|
Loading…
Reference in New Issue
Block a user