"""Fit WISP-CIS on one WristHARBench fold and score the test split (paper protocol). pip install "wisp-har[hub]" # once, for the dataset download python examples/01_benchmark_quickstart.py [--dataset adl] [--fold 0] [--seed 42] [--exported ] The first call exports the fold from the Hugging Face dataset into a local cache. With --exported, an already exported fold (//fold/*.npz) is read. With speed="exact" (default) and decoder="recipe" (the recipe's own decoder, as in the paper) the decoded labels equal the paper code, so for a catalog recipe and one of the paper seeds (42, 43, 44) the printed metrics can be compared with results/run_results.csv (see the last lines of the output). """ import argparse import csv from pathlib import Path import wisp ap = argparse.ArgumentParser() ap.add_argument("--dataset", default="adl") ap.add_argument("--fold", type=int, default=0) ap.add_argument("--seed", type=int, default=42) ap.add_argument("--recipe", default="cis") ap.add_argument("--exported", default=None) a = ap.parse_args() d = (wisp.datasets.load_exported_fold(a.exported, a.dataset, a.fold) if a.exported else wisp.datasets.load_wristharbench(a.dataset, fold=a.fold)) fit = d.train_val # fit on train+validation clf = wisp.WISPClassifier(a.recipe, decoder="recipe", classes=d.classes, random_state=a.seed) # paper decoder clf.fit(fit.X, fit.y, groups=fit.groups, time_index=fit.time_index) pred = clf.predict(d.test.X, groups=d.test.groups, time_index=d.test.time_index) scores = wisp.metrics.score(d.test.y, pred, len(d.label_names)) print({k: round(scores[k], 6) for k in ("macro_f1", "accuracy", "balanced_accuracy", "worst_class_f1")}) print(f"fit {clf.fit_seconds_:.1f} s, paper-backed configuration: {clf.has_paper_results_}") saved = Path(__file__).resolve().parents[1] / "results" / "run_results.csv" method = clf.recipe_.provenance.get("method_id") if saved.exists() and method: for row in csv.DictReader(saved.open()): if (row["dataset_id"], row["method_id"], int(row["fold"]), int(row["model_seed"])) == \ (d.dataset_id, method, a.fold, a.seed): print("saved result (results/run_results.csv):", {k: round(float(row[k]), 6) for k in ("macro_f1", "accuracy", "balanced_accuracy", "worst_class_f1")})