Fast Automatic Relevance Determination (ARD) regression and classification in Python
Project description
fastrvm
A fast and clean implementation of the Relevance Vector Machine (RVM).
fastrvm implements Tipping's "sparse Bayesian learning" algorithm [2] in a high-performance C++ core and exposes scikit-learn-compatible Python wrappers for:
- RVR — relevance vector regression
- RVC — relevance vector classification
Key benefits
- Fast training and prediction due to the greedy learning algorithm and a tuned C++ linear-algebra core (Armadillo + Einsmallen for optimization).
- Sparse models that automatically select a small set of relevance vectors.
- scikit-learn-compatible Python wrappers: plug into pipelines, grid search, and common tooling.
Quick Start
Install the latest release from PyPI (wheels are provided for Ubuntu and macOS, Windows requires building from source):
pip install fastrvm
Regression example (RVR):
from fastrvm import RVR
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
from sklearn.metrics import r2_score
X, y = make_regression(n_samples=500, n_features=50, noise=0.1, random_state=0)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
model = RVR(kernel='linear', fit_intercept=True, max_iter=2000)
model.fit(X_train, y_train)
print('R2:', r2_score(y_test, model.predict(X_test)))
Classification example (RVC)
from fastrvm import RVC
from sklearn.datasets import make_classification
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import cross_val_score
X, y = make_classification(n_samples=300, n_features=50, n_informative=10, random_state=0)
clf = make_pipeline(StandardScaler(), RVC(kernel='rbf', gamma='scale', n_jobs=-1))
scores = cross_val_score(clf, X, y, cv=5, scoring='accuracy')
print('5-fold accuracy:', scores.mean())
Notes on the Python API
- Classes:
RVRandRVCavailable fromfastrvm. - Estimator API: implements scikit-learn conventions (
fit,predict, etc.). - Kernel options:
rbf,linear,poly,precomputed(scikit-learn-style names). Various kernel hyperparameters such asgamma,degree, andcoef0are supported. - Multiclass classification: For efficiency reasons
RVCuses a one-vs-rest classifier for multiclass classification.
See docs/fastrvm.md for a short reference doc.
Installation from Source
For development install from source:
git clone https://github.com/brdav/fastrvm.git
cd fastrvm
git submodule update --init --recursive
python -m pip install -e '.[dev]'
Minimum build dependencies
- CMake >= 3.18
- Python >= 3.9 (development headers)
- C++17-capable compiler (clang, gcc, or MSVC)
- BLAS/LAPACK implementation (OpenBLAS, MKL, or Accelerate)
Note: Builds on Windows are untested in CI. You can attempt a Windows build but expect manual steps.
The C++ core (sparse Bayesian learning algorithm) can also be built independently:
cmake -S src/cpp -B build/cpp -DCMAKE_BUILD_TYPE=Release
cmake --build build/cpp --target sparsebayes -j
Citation
Key references:
-
Tipping, M. E. (2001). Sparse Bayesian Learning and the Relevance Vector Machine. Journal of Machine Learning Research, 1, 211–244.
-
Tipping, M. E. & Faul, A. C. (2003). Fast Marginal Likelihood Maximisation for Sparse Bayesian Models. Proceedings of the 4th International Workshop on Artificial Intelligence and Statistics (AISTATS / PMLR), pages 276–283, 2003.
This implementation follows the ideas and practical choices from the SparseBayes (v2.0) MATLAB package by Michael Tipping — see the SparseBayes v2.0 download page. Please cite [1] for the core algorithm and [2] for the marginal-likelihood acceleration where applicable.
License
MIT — see LICENSE for details.
Questions, feature requests, or issues? Open an issue on GitHub.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastrvm-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: fastrvm-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
471c80fe9d4f2b174380836a19445d714c27849d916566939b6bd47cd37e268a
|
|
| MD5 |
5b9af3dc3aa2ae9d7951f784306750d9
|
|
| BLAKE2b-256 |
2b4a7df7a2938db6744b9ec8c0d86e708cc1bff8767c5e8db110040ddad8a02a
|
File details
Details for the file fastrvm-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastrvm-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2ce31ba2a0b375570f17535b350c4c32961d4f8079e6001f4e86d99f1339ef1
|
|
| MD5 |
1b692534a10b5f15d983bd9a797353db
|
|
| BLAKE2b-256 |
3826191cc3cfd294e0c105e3820d12bb1abfbfd51f0b9a933dc592e11a88de3e
|
File details
Details for the file fastrvm-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: fastrvm-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b92edd111a4a0e0632fe3413dcf2241018905254fc8c958a2beb5e05b89e341e
|
|
| MD5 |
fccf7658c491998e919ccb452d543ace
|
|
| BLAKE2b-256 |
1d71ca0fa85a7735954d0c23869bb22d7573b80ace1babd8594db0cfa9a0267b
|
File details
Details for the file fastrvm-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastrvm-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b46da8b62e39ce2798443ef76a8283c6aa00b1055f26b510ff415c8faf8019a7
|
|
| MD5 |
8b998f68b9f0e3eaead72c7ef3805168
|
|
| BLAKE2b-256 |
8d103dc9803ee6cd91c05ec4d904b92ac48361babf5b72305d2a23d99d1d18ef
|
File details
Details for the file fastrvm-0.1.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: fastrvm-0.1.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04ab0c3d01718f51b7d2f346888f2246c1b403f8c941ba2744cd12a146eea0f5
|
|
| MD5 |
a7133f979dbb5e8e7b5818643f8088c7
|
|
| BLAKE2b-256 |
ad3d53406d46710ba2c73f12ab19e690bfba5baada5121e3f3cc8c8453a210cc
|
File details
Details for the file fastrvm-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: fastrvm-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52531afafc062673a39904a12ae0e56c95fb5d9a5ec8502a5c7f8f52bcfb3d2d
|
|
| MD5 |
cdf76c791e1abbd5212cd70e2e8c3f91
|
|
| BLAKE2b-256 |
03d22fe47af5ebf447583d635724804d920eef56b7625078479f957d1bbde656
|