Skip to main content

Crate libsvm_rs

Crate libsvm_rs 

Source
Expand description

§libsvm-rs

A pure Rust reimplementation of LIBSVM, targeting numerical equivalence and model-file compatibility with the original C++ library.

§Status

Phases 0–4 complete: types, I/O, kernels, cache, prediction, full SMO solver, probability estimates (Platt scaling), and cross-validation. Training works for all 5 SVM types (C-SVC, ν-SVC, one-class, ε-SVR, ν-SVR). See train::svm_train for training, predict::predict for inference, and predict::predict_probability for probabilistic outputs.

§Trust Boundary

Problem and model files are treated as untrusted text input by default. The io loaders apply LoadOptions caps, reject malformed sparse feature rows, and validate model-header consistency before allocating support-vector storage. These checks bound parsing work and memory use; they do not authenticate a model or prove that it is appropriate for a particular deployment.

§Feature Flags

  • rayon — Enable parallel cross-validation (off by default).

Re-exports§

pub use error::SvmError;
pub use io::LoadOptions;
pub use metrics::accuracy_percentage;
pub use metrics::regression_metrics;
pub use types::*;

Modules§

cache
LRU kernel cache matching the original LIBSVM.
cross_validation
Cross-validation for SVM models.
error
Error types returned by libsvm-rs.
io
I/O routines for LIBSVM problem and model files.
kernel
Kernel functions matching the original LIBSVM.
metrics
Lightweight scoring helpers for CLI outputs and test checks.
predict
Prediction functions matching the original LIBSVM.
probability
Probability estimation functions for SVM models.
qmatrix
Q matrix implementations for the SMO solver.
solver
SMO solver for the SVM dual problem.
train
SVM training pipeline.
types
Core LIBSVM-compatible data structures.
util
Shared internal utilities for libsvm-rs.

Functions§

set_quiet
Enable or disable quiet mode. When quiet, solver diagnostic messages are suppressed (equivalent to LIBSVM’s -q flag).