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/funnel/cache.py from Zipeng365/WISP: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/Zipeng365/WISP/resolve/main/src/wisp_fast/funnel/cache.py
- Command line
-
hf download hf://Zipeng365/WISP/src/wisp_fast/funnel/cache.py
-
curl -L -o cache.py https://huggingface.co/Zipeng365/WISP/resolve/main/src/wisp_fast/funnel/cache.py
1.44 kB
| """Context for shared feature blocks during a search (``_SEARCH``); ``_ACTIVE`` is never set here.""" | |
| from contextvars import ContextVar | |
| _SEARCH = ContextVar("wisp_search_memory", default=None) | |
| _ACTIVE = ContextVar("wisp_feature_store", default=None) | |
| def transform_blocks(blocks, X): | |
| config = _ACTIVE.get() | |
| shared_search = _SEARCH.get() | |
| if shared_search is not None and config is None: | |
| return shared_search.transform(blocks,X) | |
| if config is None: | |
| shared = len(blocks)>=2 and all(getattr(b,"zscore",False) and hasattr(b,"transform_normalized") for b in blocks) | |
| if shared: | |
| from wisp.cpu.features import _as_3d, _safe_zscore_per_window | |
| from . import features as fx | |
| if X.flags.c_contiguous: | |
| z=fx._normalize(_as_3d(X)) | |
| return [b.transform_normalized(z) for b in blocks] | |
| canonical=(fx.RandomConvSketch,fx.IntervalDistributionSketch,fx.WearableFeatureExtractor) | |
| if fx._time_major_view(X) and all(type(b) in canonical and not b.fast_profile for b in blocks): | |
| # Keep the original reduction layout; reuse only if the actual | |
| # normalized buffer can enter all three packed backends. | |
| z=_safe_zscore_per_window(_as_3d(X)) | |
| if z.flags.c_contiguous:return [b.transform_normalized(z) for b in blocks] | |
| return [block.transform(X) for block in blocks] | |