ium_444380/evaluate_mlflow.py
2022-05-15 20:15:27 +02:00

27 lines
665 B
Python

from sklearn.metrics import accuracy_score
import pandas as pd
from matplotlib import pyplot as plt
import numpy as np
import mlflow
mlflow.set_experiment("s444380")
test_data = pd.read_csv("out.csv")
y_true = test_data["OFFENSE_CODE_GROUP"]
y_pred = test_data["PREDICTED"]
accuracy = accuracy_score(y_true, y_pred)
mlflow.log_metric("accuracy", accuracy)
with open("eval_results.csv", "a", encoding="utf-8") as f:
f.write(f"{accuracy}\n")
eval_results = pd.read_csv("eval_results.csv", header=None).values
plt.plot(np.arange(len(eval_results)), eval_results)
plt.xlabel("Build")
plt.ylabel("Accuracy")
plt.savefig("plot.png")