Struct Svm

Source
pub struct Svm<F: Float, T> {
    pub alpha: Vec<F>,
    pub rho: F,
    /* private fields */
}
Expand description

Fitted Support Vector Machines model

This is the result of the SMO optimizer and contains the support vectors, quality of solution and optionally the linear hyperplane.

Fields§

§alpha: Vec<F>§rho: F

Implementations§

Source§

impl<F: Float, L> Svm<F, L>

Source

pub fn params() -> SvmParams<F, L>

Source§

impl<F: Float, T> Svm<F, T>

Source

pub fn nsupport(&self) -> usize

Returns the number of support vectors

This function returns the number of support vectors which have an influence on the decision outcome greater than zero.

Source

pub fn weighted_sum<D: Data<Elem = F>>(&self, sample: &ArrayBase<D, Ix1>) -> F

Sums the inner product of sample and every one of the support vectors.

§Parameters
  • sample: the input sample
§Returns

The sum of all inner products of sample and every one of the support vectors, scaled by their weight.

§Panics

If the shape of sample is not compatible with the shape of the support vectors

Trait Implementations§

Source§

impl<F: Clone + Float, T: Clone> Clone for Svm<F, T>

Source§

fn clone(&self) -> Svm<F, T>

Returns a copy 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<F: Debug + Float, T: Debug> Debug for Svm<F, T>

Source§

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

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

impl<F: Float, T> Display for Svm<F, T>

Display solution

In order to understand the solution of the SMO solver the objective, number of iterations and required support vectors are printed here.

Source§

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

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

impl<F: PartialEq + Float, T: PartialEq> PartialEq for Svm<F, T>

Source§

fn eq(&self, other: &Svm<F, T>) -> 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<F: Float, D: Data<Elem = F>> Predict<ArrayBase<D, Dim<[usize; 1]>>, Pr> for Svm<F, Pr>

Predict a probability with a feature vector

Source§

fn predict(&self, data: ArrayBase<D, Ix1>) -> Pr

Source§

impl<F: Float, D: Data<Elem = F>> Predict<ArrayBase<D, Dim<[usize; 1]>>, bool> for Svm<F, bool>

Predict a probability with a feature vector

Source§

fn predict(&self, data: ArrayBase<D, Ix1>) -> bool

Source§

impl Predict<ArrayBase<OwnedRepr<f32>, Dim<[usize; 1]>>, f32> for Svm<f32, f32>

Predict a probability with a feature vector

Source§

fn predict(&self, data: Array1<f32>) -> f32

Source§

impl Predict<ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, f64> for Svm<f64, f64>

Predict a probability with a feature vector

Source§

fn predict(&self, data: Array1<f64>) -> f64

Source§

impl<'a> Predict<ArrayBase<ViewRepr<&'a f32>, Dim<[usize; 1]>>, f32> for Svm<f32, f32>

Predict a probability with a feature vector

Source§

fn predict(&self, data: ArrayView1<'a, f32>) -> f32

Source§

impl<'a> Predict<ArrayBase<ViewRepr<&'a f64>, Dim<[usize; 1]>>, f64> for Svm<f64, f64>

Predict a probability with a feature vector

Source§

fn predict(&self, data: ArrayView1<'a, f64>) -> f64

Source§

impl<F: Float, D: Data<Elem = F>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<Pr>, Dim<[usize; 1]>>> for Svm<F, Pr>

Classify observations

This function takes a number of features and predicts target probabilities that they belong to the positive class.

Source§

fn predict_inplace(&self, data: &ArrayBase<D, Ix2>, targets: &mut Array1<Pr>)

Predict something in place
Source§

fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<Pr>

Create targets that predict_inplace works with.
Source§

impl<F: Float, D: Data<Elem = F>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<bool>, Dim<[usize; 1]>>> for Svm<F, bool>

Classify observations

This function takes a number of features and predicts target probabilities that they belong to the positive class.

Source§

fn predict_inplace(&self, data: &ArrayBase<D, Ix2>, targets: &mut Array1<bool>)

Predict something in place
Source§

fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<bool>

Create targets that predict_inplace works with.
Source§

impl<D: Data<Elem = f32>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f32>, Dim<[usize; 1]>>> for Svm<f32, f32>

Classify observations

This function takes a number of features and predicts target probabilities that they belong to the positive class.

Source§

fn predict_inplace(&self, data: &ArrayBase<D, Ix2>, targets: &mut Array1<f32>)

Predict something in place
Source§

fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<f32>

Create targets that predict_inplace works with.
Source§

impl<D: Data<Elem = f64>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for Svm<f64, f64>

Classify observations

This function takes a number of features and predicts target probabilities that they belong to the positive class.

Source§

fn predict_inplace(&self, data: &ArrayBase<D, Ix2>, targets: &mut Array1<f64>)

Predict something in place
Source§

fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<f64>

Create targets that predict_inplace works with.
Source§

impl<F: Float, T> StructuralPartialEq for Svm<F, T>

Auto Trait Implementations§

§

impl<F, T> Freeze for Svm<F, T>
where F: Freeze,

§

impl<F, T> RefUnwindSafe for Svm<F, T>

§

impl<F, T> Send for Svm<F, T>
where T: Send,

§

impl<F, T> Sync for Svm<F, T>
where T: Sync,

§

impl<F, T> Unpin for Svm<F, T>
where T: Unpin,

§

impl<F, T> UnwindSafe for Svm<F, T>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'a, F, D, DM, T, O> Predict<&'a ArrayBase<D, DM>, T> for O
where D: Data<Elem = F>, DM: Dimension, O: PredictInplace<ArrayBase<D, DM>, T>,

Source§

fn predict(&self, records: &'a ArrayBase<D, DM>) -> T

Source§

impl<'a, F, R, T, S, O> Predict<&'a DatasetBase<R, T>, S> for O
where R: Records<Elem = F>, O: PredictInplace<R, S>,

Source§

fn predict(&self, ds: &'a DatasetBase<R, T>) -> S

Source§

impl<F, D, E, T, O> Predict<ArrayBase<D, Dim<[usize; 2]>>, DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>> for O
where D: Data<Elem = F>, T: AsTargets<Elem = E>, O: PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, T>,

Source§

fn predict( &self, records: ArrayBase<D, Dim<[usize; 2]>>, ) -> DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>

Source§

impl<F, R, T, E, S, O> Predict<DatasetBase<R, T>, DatasetBase<R, S>> for O
where R: Records<Elem = F>, S: AsTargets<Elem = E>, O: PredictInplace<R, S>,

Source§

fn predict(&self, ds: DatasetBase<R, T>) -> DatasetBase<R, S>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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