KernelSum

Struct KernelSum 

Source
pub struct KernelSum<T, U>
where T: Kernel, U: Kernel,
{ /* private fields */ }
Expand description

The sum of two kernels

This struct should not be directly instantiated but instead is created when we add two kernels together.

Note that it will be more efficient to implement the final kernel manually yourself. However this provides an easy mechanism to test different combinations.

§Examples

use rusty_machine::learning::toolkit::kernel::{Kernel, Polynomial, HyperTan, KernelArith};

let poly_ker = Polynomial::new(1f64,2f64,3f64);
let hypert_ker = HyperTan::new(1f64,2.5);

let poly_plus_hypert_ker = KernelArith(poly_ker) + KernelArith(hypert_ker);

println!("{0}", poly_plus_hypert_ker.kernel(&[1f64,2f64,3f64],
                                            &[3f64,1f64,2f64]));

Trait Implementations§

Source§

impl<T, U> Debug for KernelSum<T, U>
where T: Kernel + Debug, U: Kernel + Debug,

Source§

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

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

impl<T, U> Kernel for KernelSum<T, U>
where T: Kernel, U: Kernel,

Computes the sum of the two associated kernels.

Source§

fn kernel(&self, x1: &[f64], x2: &[f64]) -> f64

The kernel function. Read more

Auto Trait Implementations§

§

impl<T, U> Freeze for KernelSum<T, U>
where T: Freeze, U: Freeze,

§

impl<T, U> RefUnwindSafe for KernelSum<T, U>

§

impl<T, U> Send for KernelSum<T, U>
where T: Send, U: Send,

§

impl<T, U> Sync for KernelSum<T, U>
where T: Sync, U: Sync,

§

impl<T, U> Unpin for KernelSum<T, U>
where T: Unpin, U: Unpin,

§

impl<T, U> UnwindSafe for KernelSum<T, U>
where T: UnwindSafe, U: 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> 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.