Struct SparseSVM

Source
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

Source

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.

Source

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.

Source

pub const fn attributes(&self) -> usize

Returns number of attributes, reflecting the libSVM model.

Source

pub fn classes(&self) -> usize

Returns number of classes, reflecting the libSVM model.

Trait Implementations§

Source§

impl From<&SparseSVM> for SparseFeatures

Source§

fn from(svm: &SparseSVM) -> Self

Converts to this type from the input type.
Source§

impl<'a> TryFrom<&'a ModelFile<'_>> for SparseSVM

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(raw_model: &'a ModelFile<'_>) -> Result<Self, Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a str> for SparseSVM

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(input: &'a str) -> Result<Self, Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.