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 src/wisp_fast/selection.py from Zipeng365/WISP: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/Zipeng365/WISP/resolve/main/src/wisp_fast/selection.py
- Command line
-
hf download hf://Zipeng365/WISP/src/wisp_fast/selection.py
-
curl -L -o selection.py https://huggingface.co/Zipeng365/WISP/resolve/main/src/wisp_fast/selection.py
1.21 kB
| """Split checks and the fit call shared by the accelerated search.""" | |
| import numpy as np | |
| def check_splits(*parts): | |
| """Require sequence metadata, one global vocabulary and disjoint group IDs.""" | |
| first = parts[0] | |
| if not first.label_names: | |
| raise ValueError("Supply the ordered global label_names") | |
| seen = set() | |
| for data in parts: | |
| if data.label_names != first.label_names or data.X.shape[1:] != first.X.shape[1:]: | |
| raise ValueError("Split vocabularies and time/channel shapes must match") | |
| if data.subject is None or data.time_index is None or not len(data.y): | |
| raise ValueError("Every split needs nonempty windows, subject and time_index") | |
| if np.min(data.y) < 0 or np.max(data.y) >= len(first.label_names): | |
| raise ValueError("Class ID outside supplied global vocabulary") | |
| groups = set(np.asarray(data.subject).astype(str)) | |
| if groups & seen: | |
| raise ValueError("Participant/sequence groups overlap between splits") | |
| seen |= groups | |
| def fit_on(model, data): | |
| return model.fit(data.X, data.y, groups=data.subject, time_index=data.time_index, | |
| n_classes=data.n_classes) | |