faissknn
faissknn contains implementations for both multiclass and multilabel K-Nearest Neighbors Classifier implementations. The classifiers follow the scikit-learn: fit, predict, and predict_proba methods.
Install
faissknn needs a FAISS backend, which you choose at install time via an extra. Pick exactly one — they ship the same faiss module and can't coexist. For CPU (works everywhere — macOS, Windows, Linux; no GPU, CUDA driver, or system toolkit required):
pip install "faissknn[cpu]"
This pulls in faiss-cpu along with numpy and torch.
A bare
pip install faissknninstalls no FAISS backend and raises a clear error at import time telling you to pick an extra. Always install one of[cpu]or[cuda].
GPU acceleration
On Linux x86_64 with an NVIDIA driver (R525+), use the [cuda] extra, which installs faiss-cuda (Taylor Geospatial's GPU wheels, CUDA 12.8, arch sm_70/80/86/89/90: V100, A100, A10/A30/RTX-30, RTX-40, H100/H200 — T4/Blackwell/RTX-50 pending a PyPI size-limit increase) instead of faiss-cpu. No system CUDA toolkit needed — the runtime libraries come from nvidia-cuda-runtime-cu12 / nvidia-cublas-cu12 on PyPI. The GPU wheel contains the full CPU implementation too, so it also works on GPU-less machines.
pip install "faissknn[cuda]"
uv/pip can't auto-detect the host CUDA driver, so the backend is a manual choice. Because nothing is installed until you pick an extra, a fresh install of any single extra is clean — no base faiss-cpu to fight, no uninstall/reinstall dance. If you later want to switch backends in the same environment, uninstall the current one first (e.g. pip uninstall -y faiss-cpu) before installing the other extra, since the FAISS packages share the faiss module and can't coexist.
Usage
Multiclass:
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from faissknn import FaissKNNClassifier
x, y = make_classification()
x_train, x_test, y_train, y_test = train_test_split(x, y)
model = FaissKNNClassifier(
n_neighbors=5,
n_classes=None,
device="cpu"
)
model.fit(x_train, y_train)
y_pred = model.predict(x_test) # (N,)
y_proba = model.predict_proba(x_test) # (N, C)
Multilabel:
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from faissknn import FaissKNNMultilabelClassifier
x, y = make_multilabel_classification()
x_train, x_test, y_train, y_test = train_test_split(x, y)
model = FaissKNNMultilabelClassifier(
n_neighbors=5,
device="cpu"
)
model.fit(x_train, y_train)
y_pred = model.predict(x_test) # (N, C)
y_proba = model.predict_proba(x_test) # (N, C)
GPU/CUDA: faissknn also supports running on the GPU to speed up computation. Simply change the device to cuda or a specific cuda device cuda:0
model = FaissKNNClassifier(
n_neighbors=5,
device="cuda"
)
model = FaissKNNClassifier(
n_neighbors=5,
device="cuda:0"
)
Cite
If you use faissknn in your research, please considering citing!
@software{isaac_corley_2026_18370748,
author = {Isaac Corley},
title = {isaaccorley/faissknn: Zenodo Cite},
month = jan,
year = 2026,
publisher = {Zenodo},
version = {v0.0.3},
doi = {10.5281/zenodo.18370748},
url = {https://doi.org/10.5281/zenodo.18370748},
}
Metadata
Release files for faissknn 0.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| faissknn-0.4.2.tar.gz | 7.8 kB | Without provenance | Details for faissknn-0.4.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| faissknn-0.4.2-py3-none-any.whl | Python 3 | none | any | Details for faissknn-0.4.2-py3-none-any.whl |
Total release size: 15.0 kB
Release files / faissknn-0.4.2.tar.gz
| Download URL | faissknn-0.4.2.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3492a435d07708b628076354728e85d7ee6835307b9ab18a8a69beba36ec367
|
|
BLAKE2b-256 checksum How to use checksums |
53e4a617dae7e06f3d9d91669b1de2fc10e69457e26c470effa9abe6fcc53aaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / faissknn-0.4.2-py3-none-any.whl
| Download URL | faissknn-0.4.2-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b10656e4c0918ebd19b538311c016c2dbc739f08299eba2f00f4e36a4143503
|
|
BLAKE2b-256 checksum How to use checksums |
82be163de38e3b55f7d2b9d60858945248e340bb2e12458fe212126cc69c043d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for faissknn 0.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.