Zaktualizuj 'train-mlflow.py'

This commit is contained in:
Kornelia Girejko 2022-05-15 22:09:51 +02:00
parent 1a8e3002e0
commit d7550ec07f

View File

@ -103,7 +103,16 @@ def my_main(epochs):
#result = open("output",'w+')
#result.write(f'{y_predicted}')
input_example = np.array([X_testing.numpy()[0]])
rmse = mean_squared_error(y_testing, y_predicted)
#print(rmse)
mae = mean_absolute_error(y_testing, y_predicted)
#print(mae)
mlflow.log_metric("rmse", rmse)
mlflow.log_metric("mae", mae)
input_example = np.array([X_testing[0]])
siganture = mlflow.models.signature.infer_signature(np.array(X_training.detach().numpy()), np.array(y_predicted_train.detach().numpy()))
tracking_url_type_store = urlparse(mlflow.get_tracking_uri()).scheme
@ -114,15 +123,6 @@ def my_main(epochs):
mlflow.pytorch.log_model(model, "model_new", signature=siganture, input_example=input_example)
#mlflow.pytorch.save_model(model, "model_new", signature=siganture, input_example=input_example)
rmse = mean_squared_error(y_testing, y_predicted)
#print(rmse)
mae = mean_absolute_error(y_testing, y_predicted)
#print(mae)
mlflow.log_metric("rmse", rmse)
mlflow.log_metric("mae", mae)
#with open('metrics.txt', 'a+') as f:
#f.write('Root mean squared error:' + str(rmse) + '\n')
#f.write('Mean absolute error:' + str(mae) + '\n')