Remove nested directory: BitTransformerLM/bit_transformer/dashboard.py
Browse files
BitTransformerLM/bit_transformer/dashboard.py
DELETED
|
@@ -1,58 +0,0 @@
|
|
| 1 |
-
import matplotlib.pyplot as plt
|
| 2 |
-
from typing import Dict, List, Tuple
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
def plot_telemetry(
|
| 6 |
-
metrics_log: Dict[str, List[float]],
|
| 7 |
-
k_floor: float = 0.5,
|
| 8 |
-
c_floor: float = 0.3,
|
| 9 |
-
s_floor: float = 0.5,
|
| 10 |
-
) -> Tuple[plt.Figure, List[plt.Axes]]:
|
| 11 |
-
"""Plot K, C, S metrics over time with cluster transitions.
|
| 12 |
-
|
| 13 |
-
Args:
|
| 14 |
-
metrics_log: Dictionary with keys ``negentropy``, ``lz_complexity``,
|
| 15 |
-
``symbiosis_score`` and optional ``clusters`` listing cluster
|
| 16 |
-
assignments per step.
|
| 17 |
-
k_floor: Threshold for negentropy (K).
|
| 18 |
-
c_floor: Threshold for LZ complexity (C).
|
| 19 |
-
s_floor: Threshold for symbiosis score (S).
|
| 20 |
-
|
| 21 |
-
Returns:
|
| 22 |
-
(figure, axes) tuple for further customization or saving.
|
| 23 |
-
"""
|
| 24 |
-
steps = list(range(len(metrics_log.get("negentropy", []))))
|
| 25 |
-
fig, axes = plt.subplots(3, 1, sharex=True, figsize=(10, 6))
|
| 26 |
-
metrics = [
|
| 27 |
-
("negentropy", k_floor, "K"),
|
| 28 |
-
("lz_complexity", c_floor, "C"),
|
| 29 |
-
("symbiosis_score", s_floor, "S"),
|
| 30 |
-
]
|
| 31 |
-
for ax, (key, floor, label) in zip(axes, metrics):
|
| 32 |
-
values = metrics_log.get(key, [])
|
| 33 |
-
ax.plot(steps, values, label=label)
|
| 34 |
-
ax.axhline(floor, color="r", linestyle="--", linewidth=1)
|
| 35 |
-
violations = [i for i, v in enumerate(values) if v < floor]
|
| 36 |
-
if violations:
|
| 37 |
-
ax.scatter(
|
| 38 |
-
[steps[i] for i in violations],
|
| 39 |
-
[values[i] for i in violations],
|
| 40 |
-
color="r",
|
| 41 |
-
zorder=5,
|
| 42 |
-
label="violation",
|
| 43 |
-
)
|
| 44 |
-
ax.set_ylabel(label)
|
| 45 |
-
ax.legend(loc="upper right")
|
| 46 |
-
|
| 47 |
-
clusters = metrics_log.get("clusters")
|
| 48 |
-
if clusters is not None:
|
| 49 |
-
prev = clusters[0]
|
| 50 |
-
for t, c in enumerate(clusters):
|
| 51 |
-
if t > 0 and c != prev:
|
| 52 |
-
for ax in axes:
|
| 53 |
-
ax.axvline(t, color="gray", linestyle=":", alpha=0.5)
|
| 54 |
-
prev = c
|
| 55 |
-
|
| 56 |
-
axes[-1].set_xlabel("step")
|
| 57 |
-
plt.tight_layout()
|
| 58 |
-
return fig, axes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|