Skip to main content

Relevance Vector Machine in Python with a C++ Core

Project description

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.

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fastrvm-0.1.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fastrvm-0.1.4-cp314-cp314-macosx_11_0_arm64.whl (223.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

fastrvm-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fastrvm-0.1.4-cp313-cp313-macosx_11_0_arm64.whl (223.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

fastrvm-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fastrvm-0.1.4-cp312-cp312-macosx_11_0_arm64.whl (222.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

fastrvm-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fastrvm-0.1.4-cp311-cp311-macosx_11_0_arm64.whl (222.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

fastrvm-0.1.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

fastrvm-0.1.4-cp310-cp310-macosx_11_0_arm64.whl (221.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file fastrvm-0.1.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastrvm-0.1.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 413045dbbe403ead7b5dfba56705b9df78a46e6aed80b49696934b821b318ee2
MD5 e8695519d9386ccc476a1fe88f71be0d
BLAKE2b-256 4703f943e6d8e61312cdc2d61d1922d9fa6edadd7f88888bf38be6051c67003a

See more details on using hashes here.

File details

Details for the file fastrvm-0.1.4-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastrvm-0.1.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b32fb403045aeabdbf6e4db2483be5a44f8aeac9b8aa995f78d33f687340f8f
MD5 09e6bfe0ad66d79126bd920757a7e1c1
BLAKE2b-256 ace215d05d97190a6ca024341255766ca75ff909bc3979c70bfa09b4791547f7

See more details on using hashes here.

File details

Details for the file fastrvm-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastrvm-0.1.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4f9ec999043b6782ce124ff666fdee9fd7a57bf304b8929664cc5efafafbc784
MD5 cbc3ef5916514bf913cafe61d1d9e8aa
BLAKE2b-256 d4b42b566080ccb71211a1c8e8320370c4ab7cac38c3cc3088783270be118b59

See more details on using hashes here.

File details

Details for the file fastrvm-0.1.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastrvm-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 298831f350567bb88b555ddc0be7a03fbb2a0f813a52fa36ccda7dc1e6056423
MD5 467321019ca167e7371d04d5cc1157f5
BLAKE2b-256 bf657f3f53f05745d85c8a49fb568f42f754a34d60c0d77b004f5323b4aa304d

See more details on using hashes here.

File details

Details for the file fastrvm-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastrvm-0.1.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ca331f884f0f891af8cf13070fe69a26f69456519742ecd2ddef149879d62ace
MD5 3c9da20a53f42f621b7c610f8400522e
BLAKE2b-256 6d1c3867e7e82aa94273ab4518c962609b5c7cf211e3a88f4037afb80a152635

See more details on using hashes here.

File details

Details for the file fastrvm-0.1.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastrvm-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d556fd1ffba1cb4cb1a156f0b18a733d768b282de7298cd41b39bb130870ee9f
MD5 04b186e2c3392dffb3f1a7c721be6929
BLAKE2b-256 8fc6fd6481f60cd2094a3cb94bd048cae8b61f99c37367aff15b8243f2d3560a

See more details on using hashes here.

File details

Details for the file fastrvm-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastrvm-0.1.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 147e12979b150cb960995db19228dccb152ada639e62a313797710018a1468e3
MD5 00ff36412620793e3d27f71d0e7d1b31
BLAKE2b-256 701820ab7d481c734088a4c65b94ca76ff8a68435121e0a24ac3b3df92914c16

See more details on using hashes here.

File details

Details for the file fastrvm-0.1.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastrvm-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e6b73aeea949463adb20d5372484195e6f4f78b092faf8d6c1272468ecf7c250
MD5 a8eeb8d6016a0acc66ec66394babd508
BLAKE2b-256 47589d214562b50cd2c686e0e99bde491e824be51b914968a5452506d9fff797

See more details on using hashes here.

File details

Details for the file fastrvm-0.1.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fastrvm-0.1.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c3dd5943b51fcaf318a61cabfa5fb12e2d70afc1c29fa61999ad97b33ad528d
MD5 f44de046e14fb8974dd5b23467965c7f
BLAKE2b-256 be52fe63f7fbe1688c87482f2f6050c1c1a8d32e0774e19670eb85609003e2f1

See more details on using hashes here.

File details

Details for the file fastrvm-0.1.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fastrvm-0.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a8a9b3054b5134775bc55972ef5f696d4182002bb5d7ac7b0bf6c24949f0b347
MD5 5dd96ac91bdd55a5e0f81d4ea2092fd7
BLAKE2b-256 7efc54f4f679220d257a69db56ca6cd4e61e1f52cd3ca92c70626550c1d198d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page