Datasets:
File size: 1,367 Bytes
6f32cc3 | 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 | """Check uniformity: realized inclusion rate (kept bases / characters streamed) per subset and split, vs the target.
python check_rates.py [--root .] [--split train]
A per-base uniform sample keeps rate * (sequence characters) per subset; characters streamed also count tag and
separator characters, so a subset with many tags or separators shows a slightly lower realized rate.
"""
from __future__ import annotations
import argparse
import json
from collections import defaultdict
from pathlib import Path
def main() -> None:
ap = argparse.ArgumentParser()
ap.add_argument("--root", type=Path, default=Path("."))
ap.add_argument("--split", default="train")
a = ap.parse_args()
agg = defaultdict(lambda: [0, 0, 0, 0.0])
for done in sorted((a.root / a.split).glob("*/*.done")):
st = json.loads(done.read_text())
g = agg[done.parent.name]
g[0] += st["kept_bases"]
g[1] += st["chars_seen"]
g[2] += st["records"]
g[3] = st["rate"]
print(f"{'subset':<28} {'records':>12} {'chars/record':>13} {'kept/chars':>11} {'ratio to rate':>14}")
for k, (kept, chars, recs, rate) in sorted(agg.items(), key=lambda kv: -kv[1][1]):
r = kept / max(chars, 1)
print(f"{k:<28} {recs:12d} {chars / max(recs, 1):13.0f} {r:11.3e} {r / rate:14.3f}")
if __name__ == "__main__":
main()
|