first version of the plot

This commit is contained in:
Maximilian Kany
2025-08-15 11:38:46 +02:00
parent 7421171bb0
commit ee6a31972b
41 changed files with 38 additions and 1523 deletions

38
plot_maker.py Normal file
View File

@@ -0,0 +1,38 @@
import os
import matplotlib.pyplot as plt
datasets = {
"cleaned": "games_march2025_cleaned",
"cleaned_2k": "games_march2025_cleaned_2k",
"cleaned_10k": "games_march2025_cleaned_10k"
}
# def results
results = {}
for dataset_name, folder in datasets.items():
results[dataset_name] = {}
for filename in os.listdir(folder):
if filename.endswith(".txt"):
model_name = filename.replace(".txt", "")
with open(os.path.join(folder, filename), "r") as f:
for line in f:
if line.strip().startswith("weighted avg"):
parts = line.split()
f1_score = float(parts[3]) # precision recall f1-score support
results[dataset_name][model_name] = f1_score
# Plot
models = sorted(results["cleaned"].keys()) # alphabetisch sortieren für gleiche Reihenfolge
x = range(len(models))
plt.figure(figsize=(12,6))
plt.bar([i - 0.25 for i in x], [results["cleaned"][m] for m in models], width=0.25, label="cleaned")
plt.bar(x, [results["cleaned_2k"][m] for m in models], width=0.25, label="cleaned_2k")
plt.bar([i + 0.25 for i in x], [results["cleaned_10k"][m] for m in models], width=0.25, label="cleaned_10k")
plt.xticks(x, models, rotation=45)
plt.ylabel("Weighted F1-Score")
plt.title("Model Performance across Datasets")
plt.legend()
plt.tight_layout()
plt.show()