Instructions to use Zipeng365/WISP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Zipeng365/WISP with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Zipeng365/WISP", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Download benchmarks/_frozen.py from Zipeng365/WISP: direct link, hf CLI and curl.
- Browser
- Download file 2.18 kB
-
https://huggingface.co/Zipeng365/WISP/resolve/main/benchmarks/_frozen.py
- Command line
-
hf download hf://Zipeng365/WISP/benchmarks/_frozen.py
-
curl -L -o _frozen.py https://huggingface.co/Zipeng365/WISP/resolve/main/benchmarks/_frozen.py
2.18 kB
| """Read frozen WristHARBench fold exports (train/valid/test NPZ) for the package benchmarks. | |
| Only numeric arrays are read (``allow_pickle=False``); the global label vocabulary is | |
| taken from the fold's ``export_manifest.json``. ``X`` is converted to float64 exactly | |
| as the paper runners did, and train+validation are concatenated in that order. | |
| """ | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| import numpy as np | |
| STREAMS = ( | |
| "adl_wrist_accel_v1", "capture24_wearable_activity_v1", "domino_watch_accel_v1", | |
| "gotov_wrist_accel_v1", "handy_wrist_accel_v1", "harmes_left_wrist_accel_v1", | |
| "harmes_right_wrist_accel_v1", "iuwds_wrist_accel_v1", "mhealth_right_lower_arm_v1", | |
| "paal_adl_wrist_accel_v1", "pamap2_hand_imu_v1", "wisdm_watch_accel_v1", | |
| ) | |
| def load_part(root, dataset, fold, part): | |
| folder = Path(root) / dataset / f"fold{int(fold)}" | |
| manifest = json.loads((folder / "export_manifest.json").read_text()) | |
| with np.load(folder / f"{part}.npz", allow_pickle=False) as z: | |
| out = {"X": np.asarray(z["X"], dtype=np.float64), "y": np.asarray(z["y"], dtype=np.int64), | |
| "subject": np.asarray(z["subject"]), "time_index": np.asarray(z["time_index"])} | |
| out["label_names"] = list(manifest["label_names"]) | |
| out["n_classes"] = int(manifest["n_classes"]) | |
| return out | |
| def concat(a, b): | |
| out = {k: np.concatenate([a[k], b[k]], axis=0) for k in ("X", "y", "subject", "time_index")} | |
| out["label_names"], out["n_classes"] = a["label_names"], a["n_classes"] | |
| return out | |
| def load_fold(root, dataset, fold): | |
| """Return (train, valid, train+valid, test) dictionaries.""" | |
| train, valid, test = (load_part(root, dataset, fold, p) for p in ("train", "valid", "test")) | |
| return train, valid, concat(train, valid), test | |
| def paper_scores(y_true, y_pred, n_classes): | |
| """The frozen four-metric definitions used by the release (``wisp_release.scoring``).""" | |
| from wisp_release.scoring import score | |
| s = score(np.asarray(y_true, dtype=np.int64), np.asarray(y_pred, dtype=np.int64), int(n_classes)) | |
| return {k: s[k] for k in ("macro_f1", "accuracy", "balanced_accuracy", "worst_class_f1")} | |