IUM_s464980/predict.py

34 lines
881 B
Python
Raw Normal View History

import pandas as pd
from tensorflow import keras
import numpy as np
from sklearn.metrics import root_mean_squared_error
2024-05-14 22:41:29 +02:00
import matplotlib.pyplot as plt
np.set_printoptions(threshold=np.inf)
2024-05-15 00:30:21 +02:00
data = pd.read_csv("MLFLOW/df_test.csv")
X_test = data.drop("Performance Index", axis=1)
y_test = data["Performance Index"]
model = keras.models.load_model("model.keras")
predictions = model.predict(X_test)
with open("predictions.txt", "w") as f:
f.write(str(predictions))
2024-05-14 22:17:35 +02:00
2024-05-14 23:09:01 +02:00
rmse = root_mean_squared_error(y_test, predictions)
2024-05-14 22:24:34 +02:00
with open("rmse.txt", 'a') as file:
2024-05-14 23:09:01 +02:00
file.write(str(rmse)+"\n")
2024-05-14 22:41:29 +02:00
with open("rmse.txt", 'r') as file:
lines = file.readlines()
num_lines = len(lines)
lines = [float(line.replace("\n", "")) for line in lines]
plt.plot(range(1, num_lines+1), lines)
plt.xlabel("Build number")
plt.ylabel("RMSE value")
plt.title("RMSE")
plt.savefig("rmse.jpg")