Skip to main content

fastrvm

Build Wheels PyPI version Python Versions License

A fast and clean implementation of the Relevance Vector Machine (RVM).

fastrvm teaser

fastrvm implements the accelerated RVM training algorithm described in [3] 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: RVR and RVC available from fastrvm.
  • Estimator API: implements scikit-learn conventions (fit, predict, etc.).
  • Kernel options: rbf, linear, poly, precomputed (scikit-learn-style names). Various kernel hyperparameters such as gamma, degree, and coef0 are supported.
  • Multiclass classification: For efficiency reasons RVC uses a one-vs-rest classifier for multiclass classification.

See docs/fastrvm.md for a short reference doc.

Limitations of the RVM

While powerful and often very sparse, the RVM can be viewed as a finite, data-dependent Gaussian process (GP): the kernel is a weighted sum of basis functions centred on the training inputs (see Rasmussen and Williams, 2006, chapter 6.6). Because the prior then depends on the observed inputs and the kernel is degenerate (finite rank), this departs from a strict Bayesian GP interpretation. With localized bases (e.g., RBFs), predictions far from any relevance vector can become spuriously overconfident: both the mean and the predictive variance may collapse toward zero (or the estimated noise level) even in clear extrapolation regions. This behavior is a modeling artifact of the degenerate kernel—computationally attractive, but it can harm uncertainty quantification in out-of-support areas.

Installation from Source

For development install from source:

git clone https://github.com/brdav/fastrvm.git
cd fastrvm
python -m pip install -e '.[dev]'

Minimum build dependencies

  • CMake >= 3.18
  • Python >= 3.10 (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:

  1. Tipping, M. E. (2001). Sparse Bayesian Learning and the Relevance Vector Machine. Journal of Machine Learning Research, 1, 211–244.

  2. Faul, A. C., & Tipping, M. E. (2002). Analysis of Sparse Bayesian Learning. In Advances in Neural Information Processing Systems 14 (NeurIPS 2002).

  3. Tipping, M. E., & Faul, A. C. (2003). Fast Marginal Likelihood Maximisation for Sparse Bayesian Models. In Proceedings of the 4th International Workshop on Artificial Intelligence and Statistics (AISTATS). PMLR, 276–283.

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 [3] for the marginal-likelihood acceleration where applicable.

License

MIT — see LICENSE for details.


Questions, feature requests, or issues? Open an issue on GitHub.

Metadata

Release files for fastrvm 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for fastrvm 0.1.5
File
fastrvm-0.1.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
fastrvm-0.1.5-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
fastrvm-0.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
fastrvm-0.1.5-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
fastrvm-0.1.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
fastrvm-0.1.5-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
fastrvm-0.1.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
fastrvm-0.1.5-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
fastrvm-0.1.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
fastrvm-0.1.5-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details

Total release size: 62.8 MB

Release files / fastrvm-0.1.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL fastrvm-0.1.5-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 12.3 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f2237d795ff8a02d7796229cec0c9b9e3631157baba62cdadfd3254e3f9f040f
BLAKE2b-256 checksum
How to use checksums
225ff2748e6780db6e6af100854bd34a39d9d6e3231749eb09db176343cd8db0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / fastrvm-0.1.5-cp314-cp314-macosx_11_0_arm64.whl

Download URL fastrvm-0.1.5-cp314-cp314-macosx_11_0_arm64.whl
Size 223.7 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ad228cd6fc01f1ce4ba8025e03efc976dbfab6a3bd1ed254182495fbed752e37
BLAKE2b-256 checksum
How to use checksums
12b8e1d605ce88b598a688333abd6d89dbc79f8fecd861913c09edd13e38802c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / fastrvm-0.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL fastrvm-0.1.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 12.3 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
09268c9375e4317d2d596cf8c323dd57556a7ac925fda2a47f2fb69157e6721e
BLAKE2b-256 checksum
How to use checksums
2704d06ccba680dd15800ae6f1713699f38c908e1c3ae459db94cdbed431ffe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / fastrvm-0.1.5-cp313-cp313-macosx_11_0_arm64.whl

Download URL fastrvm-0.1.5-cp313-cp313-macosx_11_0_arm64.whl
Size 223.0 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5d141c1e53243b3efc4b1f3f9c404e4f6ccf98224905a1986280528dc34ff801
BLAKE2b-256 checksum
How to use checksums
895a7a9f51365dc4d90444d629aee3baff347797f81a0f39967351428539c656
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / fastrvm-0.1.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL fastrvm-0.1.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 12.3 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9d2b5a927c25de05057e6d62878213be992d83c6ebc09eceb438b577f51993d4
BLAKE2b-256 checksum
How to use checksums
d1de846a3376e7545a4d72ee3349dd71504c531c3b0990fba7da0d69f78b3435
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / fastrvm-0.1.5-cp312-cp312-macosx_11_0_arm64.whl

Download URL fastrvm-0.1.5-cp312-cp312-macosx_11_0_arm64.whl
Size 222.9 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
925bcf61573d25008bd9ed6661021880754ccf63a9c0c81d00a19d01c2af75ce
BLAKE2b-256 checksum
How to use checksums
a342a76870a18f0878254b24c3dab462b43f9fe1b924207671fb60db6ea8aa68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / fastrvm-0.1.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL fastrvm-0.1.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 12.3 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ebcd5c1ad8b7c0ac8e8c59b29ffec1274fa62b9fed90bbeb066b07c451da1c6e
BLAKE2b-256 checksum
How to use checksums
da2cf0511b7639c281a1e35120d7a7e8fe83c6130cfde48a60181e91c2f16c0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / fastrvm-0.1.5-cp311-cp311-macosx_11_0_arm64.whl

Download URL fastrvm-0.1.5-cp311-cp311-macosx_11_0_arm64.whl
Size 222.1 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
55b917df433c3a1197fbf35bb56fda3e5e2124e3303887339e705b0f96b5e6e9
BLAKE2b-256 checksum
How to use checksums
253a1cf16ffdd626c17a84d7356ffacde6f9291e6b110670681d75a09fd0b78c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / fastrvm-0.1.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL fastrvm-0.1.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 12.3 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
acf8e77940edbe274a2e0e5fa1e1a476347a7ca42b05ee93611e0be76e483d0c
BLAKE2b-256 checksum
How to use checksums
13eb7f9e41fb43bba5485add3dfdcf6cf48b92e2a316baea1426dbbe65720ef2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release files / fastrvm-0.1.5-cp310-cp310-macosx_11_0_arm64.whl

Download URL fastrvm-0.1.5-cp310-cp310-macosx_11_0_arm64.whl
Size 221.1 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b37896b687900f843cb806dcf7f7ec3f10df9ff611c49cbdb9555cc8dc9593ce
BLAKE2b-256 checksum
How to use checksums
ca31eb0e0598bc93b4d194218cbad86e920607d173cd16d150b33335e5d09c1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.1.5 This release

10 release files

0.1.4

10 release files

0.1.2

10 release files

0.1.1

6 release files

0.1.0

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page