-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_metacognition_hero.py
More file actions
38 lines (30 loc) · 1.2 KB
/
Copy pathplot_metacognition_hero.py
File metadata and controls
38 lines (30 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import json
import matplotlib.pyplot as plt
import numpy as np
import os
DOMAINS = [
("experiments/mnist_sci_v2", "MNIST (Vision)"),
("experiments/mitbih_sci_v2", "MIT-BIH (Medical)")
]
def plot():
plt.figure(figsize=(10, 4))
for i, (path, name) in enumerate(DOMAINS):
log = os.path.join(path, "per_example.jsonl")
if not os.path.exists(log): continue
data = []
with open(log, 'r') as f:
for l in f: data.append(json.loads(l))
corr = [d['steps'] for d in data if d['correct_sci']]
wrong = [d['steps'] for d in data if not d['correct_sci']]
plt.subplot(1, 2, i+1)
plt.hist(corr, bins=np.arange(1, 26)-0.5, alpha=0.6, density=True, label='Correct', color='green')
plt.hist(wrong, bins=np.arange(1, 26)-0.5, alpha=0.6, density=True, label='Incorrect', color='red')
plt.title(f"{name}: Adaptive Compute")
plt.xlabel("Inference Steps")
plt.ylabel("Density")
plt.legend()
plt.tight_layout()
plt.savefig("metacognition_hero.png")
print("Saved metacognition_hero.png")
if __name__ == "__main__":
plot()