Scandiumlabs commited on
Commit
c4cfcd3
·
verified ·
1 Parent(s): 165db58

Upload examples/statistics/compute_statistics.py with huggingface_hub

Browse files
examples/statistics/compute_statistics.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Example: Compute per-family and per-source statistics."""
2
+ import json
3
+ import numpy as np
4
+ from collections import Counter
5
+
6
+ with open("dataset/entries_final_v3.json") as f:
7
+ entries = json.load(f)
8
+
9
+ # Per-family statistics
10
+ families = Counter(f for e in entries for f in e.get("families", ["unknown"]))
11
+ print("Family Distribution:")
12
+ for fam, count in families.most_common():
13
+ pct = 100 * count / len(entries)
14
+ print(f" {fam:25s}: {count:>7,} ({pct:.1f}%)")
15
+
16
+ # Per-source FE distribution
17
+ print("\nFE Distribution by Source:")
18
+ for src in ["mp", "oqmd", "jarvis"]:
19
+ subset = [e for e in entries if e.get("source") == src]
20
+ fe_vals = [e.get("formation_energy_per_atom", 0) for e in subset
21
+ if e.get("formation_energy_per_atom") is not None]
22
+ print(f" {src:8s}: mean={np.mean(fe_vals):.3f} "
23
+ f"median={np.median(fe_vals):.3f} "
24
+ f"std={np.std(fe_vals):.3f} "
25
+ f"N={len(fe_vals):,}")
26
+
27
+ # Coverage analysis
28
+ print("\nProperty Coverage:")
29
+ for prop in ["formation_energy_per_atom", "energy_above_hull", "band_gap"]:
30
+ present = sum(1 for e in entries if e.get(prop) is not None)
31
+ print(f" {prop:35s}: {present:>7,} / {len(entries):,} "
32
+ f"({100*present/len(entries):.1f}%)")