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
File size: 2,182 Bytes
4731b11 | 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 39 40 41 42 43 44 45 46 47 48 49 50 | """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")}
|