MultiClassSVM

Struct MultiClassSVM 

Source
pub struct MultiClassSVM<const D: usize, K, C>
where K: Kernel<D>, C: Eq + Hash + Clone,
{ /* private fields */ }
Expand description

A fitted multi-class classification support vector machine using One-vs-One strategy.

§Type Parameters

  • D - The dimension or number of features.
  • K - The type of the kernel function.
  • C - The type of the class label.

§Strategy

Uses One-vs-One (OvO) approach: trains a binary classifier for each pair of classes. For N classes, trains N*(N-1)/2 binary classifiers. Prediction is done by majority voting.

Implementations§

Source§

impl<const D: usize, K, C> MultiClassSVM<D, K, C>
where K: Kernel<D>, C: Eq + Hash + Clone,

Source

pub fn predict(&self, x: &RowVector<D>) -> C

Predicts the class label for a given input vector using majority voting.

§Arguments
  • x - The input feature vector.
§Returns

The predicted class label.

Source

pub fn predict_with_votes(&self, x: &RowVector<D>) -> (C, Vec<(C, usize)>)

Predicts the class label and returns vote counts for all classes.

§Arguments
  • x - The input feature vector.
§Returns

A tuple of (predicted_class, votes_per_class).

Source

pub const fn num_classes(&self) -> usize

Returns the number of classes.

Source

pub fn num_classifiers(&self) -> usize

Returns the number of binary classifiers.

Source

pub fn classes(&self) -> &[C]

Returns a reference to the list of class labels.

Trait Implementations§

Source§

impl<const D: usize, K, C> Clone for MultiClassSVM<D, K, C>
where K: Kernel<D> + Clone, C: Eq + Hash + Clone + Clone,

Source§

fn clone(&self) -> MultiClassSVM<D, K, C>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const D: usize, K, C> Debug for MultiClassSVM<D, K, C>
where K: Kernel<D> + Debug, C: Eq + Hash + Clone + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const D: usize, K, C> PartialEq for MultiClassSVM<D, K, C>
where K: Kernel<D> + PartialEq, C: Eq + Hash + Clone + PartialEq,

Source§

fn eq(&self, other: &MultiClassSVM<D, K, C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const D: usize, K, C> StructuralPartialEq for MultiClassSVM<D, K, C>
where K: Kernel<D>, C: Eq + Hash + Clone,

Auto Trait Implementations§

§

impl<const D: usize, K, C> Freeze for MultiClassSVM<D, K, C>

§

impl<const D: usize, K, C> RefUnwindSafe for MultiClassSVM<D, K, C>

§

impl<const D: usize, K, C> Send for MultiClassSVM<D, K, C>
where C: Send, K: Send,

§

impl<const D: usize, K, C> Sync for MultiClassSVM<D, K, C>
where C: Sync, K: Sync,

§

impl<const D: usize, K, C> Unpin for MultiClassSVM<D, K, C>
where C: Unpin, K: Unpin,

§

impl<const D: usize, K, C> UnwindSafe for MultiClassSVM<D, K, C>
where C: UnwindSafe, K: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,