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/forest_kernels.c from Zipeng365/WISP: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/Zipeng365/WISP/resolve/main/src/wisp_fast/funnel/forest_kernels.c
- Command line
-
hf download hf://Zipeng365/WISP/src/wisp_fast/funnel/forest_kernels.c
-
curl -L -o forest_kernels.c https://huggingface.co/Zipeng365/WISP/resolve/main/src/wisp_fast/funnel/forest_kernels.c
1.59 kB
| /* Read the dtype/strides verified by forest.py; never assume an sklearn C struct layout. | |
| The table contains pointers to non-owning array views pinned by the Python plan. | |
| f32 inputs, f64 comparisons and tree-order f64 sums match sklearn's serial path. */ | |
| static intptr_t read_index(uintptr_t p) { | |
| intptr_t out; | |
| memcpy(&out, (const void *)p, sizeof out); | |
| return out; | |
| } | |
| static double read_double(uintptr_t p) { | |
| double out; | |
| memcpy(&out, (const void *)p, sizeof out); | |
| return out; | |
| } | |
| __declspec(dllexport) | |
| void wisp_forest(const float *x, intptr_t n, intptr_t d, | |
| const uintptr_t *specs, intptr_t nt, intptr_t k, double *out) { | |
| for (intptr_t t = 0; t < nt; ++t) { | |
| const uintptr_t *tree = specs + 8 * t; | |
| const uintptr_t stride = tree[6]; | |
| for (intptr_t i = 0; i < n; ++i) { | |
| intptr_t node = 0, left; | |
| uintptr_t off = 0; | |
| while ((left = read_index(tree[0] + off)) != -1) { | |
| const float val = x[i*d + read_index(tree[2]+off)]; | |
| const int go_left = isnan(val) ? *(const uint8_t *)(tree[5]+off) | |
| : (double)val <= read_double(tree[3]+off); | |
| node = go_left ? left : read_index(tree[1]+off); | |
| off = (uintptr_t)node * stride; | |
| } | |
| const double *leaf = (const double *)(tree[4] + (uintptr_t)node * tree[7]); | |
| for (intptr_t j = 0; j < k; ++j) out[i*k+j] += leaf[j]; | |
| } | |
| } | |
| } | |