+
+
+
+
+
+
+In [2]:
+
+
+
+
+
+import json
+import pandas as pd
+import matplotlib.pyplot as plt
+import seaborn as sns
+from pathlib import Path
+
+LOG_PATH = Path("../models/multilabel/training_log.json")
+
+with open(LOG_PATH, encoding="utf-8") as f:
+ data = json.load(f)
+
+print(f"🔢 Wczytano {len(data)} rekordów")
+
+
+
+
+
+
+
+
+
+
+
+🔢 Wczytano 373 rekordów ++
+
+
+
+
+
+
+In [3]:
+
+
+
+
+
+df = pd.DataFrame(data)
+df.head(10)
+
+
+
+
+
+
+
+
+Out[3]:
+
+
+
+
+
+
+
+
++ | loss | +grad_norm | +learning_rate | +epoch | +step | +eval_loss | +eval_accuracy | +eval_f1 | +eval_precision | +eval_recall | +eval_runtime | +eval_samples_per_second | +eval_steps_per_second | +train_runtime | +train_samples_per_second | +train_steps_per_second | +total_flos | +train_loss | +
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | +0.4904 | +0.595887 | +0.000020 | +0.03 | +50 | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +
1 | +0.3657 | +0.460212 | +0.000020 | +0.07 | +100 | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +
2 | +0.3182 | +0.615664 | +0.000020 | +0.10 | +150 | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +
3 | +0.2750 | +0.463075 | +0.000020 | +0.13 | +200 | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +
4 | +0.2520 | +0.639511 | +0.000020 | +0.17 | +250 | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +
5 | +0.2434 | +0.450176 | +0.000020 | +0.20 | +300 | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +
6 | +0.2208 | +0.661054 | +0.000020 | +0.23 | +350 | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +
7 | +0.2192 | +0.402220 | +0.000020 | +0.27 | +400 | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +
8 | +0.2138 | +0.729939 | +0.000019 | +0.30 | +450 | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +
9 | +0.2066 | +0.564321 | +0.000019 | +0.33 | +500 | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +NaN | +
+
+
+
+
+
+
+In [4]:
+
+
+
+
+
+metric_cols = [col for col in df.columns if isinstance(df[col].dropna().iloc[0], (int, float))]
+print(f"📐 Metryki numeryczne: {metric_cols}")
+
+
+
+
+
+
+
+
+
+
+
+📐 Metryki numeryczne: ['loss', 'grad_norm', 'learning_rate', 'epoch', 'eval_loss', 'eval_accuracy', 'eval_f1', 'eval_precision', 'eval_recall', 'eval_runtime', 'eval_samples_per_second', 'eval_steps_per_second', 'train_runtime', 'train_samples_per_second', 'train_steps_per_second', 'total_flos', 'train_loss'] ++
+
+
+
+
+
+
+In [5]:
+
+
+
+
+
+plt.figure(figsize=(10, 5))
+sns.lineplot(data=df, x="epoch", y="loss", label="loss", marker="o")
+if "eval_loss" in df.columns:
+ sns.lineplot(data=df, x="epoch", y="eval_loss", label="eval_loss", marker="o")
+plt.title("Strata treningowa / walidacyjna")
+plt.xlabel("Epoka")
+plt.ylabel("Strata")
+plt.grid(True)
+plt.legend()
+plt.tight_layout()
+plt.show()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+In [6]:
+
+
+
+
+
+plt.figure(figsize=(10, 5))
+if "eval_f1" in df.columns:
+ sns.lineplot(data=df, x="epoch", y="eval_f1", label="F1", marker="o")
+if "eval_accuracy" in df.columns:
+ sns.lineplot(data=df, x="epoch", y="eval_accuracy", label="Accuracy", marker="o")
+plt.title("Skuteczność metryk walidacyjnych")
+plt.xlabel("Epoka")
+plt.ylabel("Wartość metryki")
+plt.grid(True)
+plt.legend()
+plt.tight_layout()
+plt.show()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+In [7]:
+
+
+
+
+
+last_eval = df[df["epoch"] == df["epoch"].max()].dropna(axis=1)
+last_eval.T.sort_index()
+
+
+
+
+
+
+
+
+Out[7]:
+
+
+
+
+
+
+
+
++ | 370 | +371 | +372 | +
---|---|---|---|
epoch | +12.0 | +12.0 | +12.0 | +
step | +18000.0 | +18000.0 | +18000.0 | +
+
+
+
+
+
+
+In [8]:
+
+
+
+
+
+plt.figure(figsize=(10, 5))
+if "eval_precision" in df.columns:
+ sns.lineplot(data=df, x="epoch", y="eval_precision", label="Precision", marker="o")
+if "eval_recall" in df.columns:
+ sns.lineplot(data=df, x="epoch", y="eval_recall", label="Recall", marker="o")
+plt.title("Precision i Recall")
+plt.xlabel("Epoka")
+plt.ylabel("Wartość metryki")
+plt.grid(True)
+plt.legend()
+plt.tight_layout()
+plt.show()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+In [9]:
+
+
+
+
+
+if "learning_rate" in df.columns:
+ plt.figure(figsize=(10, 4))
+ sns.lineplot(data=df, x="epoch", y="learning_rate", label="Learning Rate", marker="o")
+ plt.title("Learning Rate w czasie")
+ plt.xlabel("Epoka")
+ plt.ylabel("LR")
+ plt.grid(True)
+ plt.tight_layout()
+ plt.show()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+In [10]:
+
+
+
+
+
+if "grad_norm" in df.columns:
+ plt.figure(figsize=(10, 4))
+ sns.lineplot(data=df, x="epoch", y="grad_norm", label="Gradient Norm", marker="o")
+ plt.title("Gradient Norm w czasie")
+ plt.xlabel("Epoka")
+ plt.ylabel("Norma gradientu")
+ plt.grid(True)
+ plt.tight_layout()
+ plt.show()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+In [11]:
+
+
+
+
+
+eval_cols = [col for col in df.columns if col.startswith("eval_")]
+plt.figure(figsize=(12, 6))
+for col in eval_cols:
+ sns.lineplot(data=df, x="epoch", y=col, label=col, marker="o")
+plt.title("Wszystkie metryki walidacyjne")
+plt.xlabel("Epoka")
+plt.ylabel("Wartość")
+plt.legend()
+plt.grid(True)
+plt.tight_layout()
+plt.show()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+In [ ]:
+
+
+
+
+
+
+