pub struct SparseSVM { /* private fields */ }
Expand description
an SVM optimized for large models with many empty attributes.
§Creating an SVM
This SVM can be created by passing a ModelFile
or &str
into ModelFile::try_from
:
use ffsvm::SparseSVM;
let svm = SparseSVM::try_from("...");
Implementations§
Source§impl SparseSVM
impl SparseSVM
Sourcepub fn class_index_for_label(&self, label: i32) -> Option<usize>
pub fn class_index_for_label(&self, label: i32) -> Option<usize>
Finds the class index for a given label.
§Description
This method takes a label
as defined in the libSVM training model
and returns the internal index
where this label resides. The index
equals FeatureVector::probabilities
index where that label’s
probability can be found.
§Returns
If the label was found its index returned in the Option
, otherwise None
is returned.
Sourcepub fn class_label_for_index(&self, index: usize) -> Option<i32>
pub fn class_label_for_index(&self, index: usize) -> Option<i32>
Returns the class label for a given index.
§Description
The inverse of SparseSVM::class_index_for_label
, this function returns the class label
associated with a certain internal index. The index equals the FeatureVector::probabilities
index where a label’s probability can be found.
§Returns
If the index was found it is returned in the Option
, otherwise None
is returned.
Sourcepub const fn attributes(&self) -> usize
pub const fn attributes(&self) -> usize
Returns number of attributes, reflecting the libSVM model.