pub struct KernelBase<K1: Inner, K2: Inner>{
pub inner: KernelInner<K1, K2>,
pub method: KernelMethod<K1::Elem>,
}
Expand description
A generic kernel
Fields§
§inner: KernelInner<K1, K2>
§method: KernelMethod<K1::Elem>
The inner product that will be used by the kernel
Implementations§
Source§impl<F: Float, K1: Inner<Elem = F>, K2: Inner<Elem = F>> KernelBase<K1, K2>
impl<F: Float, K1: Inner<Elem = F>, K2: Inner<Elem = F>> KernelBase<K1, K2>
Sourcepub fn params() -> KernelParams<F, CommonNearestNeighbour>
pub fn params() -> KernelParams<F, CommonNearestNeighbour>
Generates the default set of parameters for building a kernel.
Use this to initialize a set of parameters to be customized using KernelParams
’s methods
Sourcepub fn params_with_nn<N: NearestNeighbour>(nn_algo: N) -> KernelParams<F, N>
pub fn params_with_nn<N: NearestNeighbour>(nn_algo: N) -> KernelParams<F, N>
Generate parameters with a specific nearest neighbour algorithm
Sourcepub fn dot(&self, rhs: &ArrayView2<'_, F>) -> Array2<F>
pub fn dot(&self, rhs: &ArrayView2<'_, F>) -> Array2<F>
Sourcepub fn sum(&self) -> Array1<F>
pub fn sum(&self) -> Array1<F>
Sums all elements in the same row of the kernel matrix
§Returns
A new array with the sum of all the elements in each row
Sourcepub fn to_upper_triangle(&self) -> Vec<F>
pub fn to_upper_triangle(&self) -> Vec<F>
Getter for the data in the upper triangle of the kernel matrix
§Returns
A copy of all elements in the upper triangle of the kernel
matrix, stored in a Vec
Source§impl<'a, F: Float> KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>>
impl<'a, F: Float> KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>>
pub fn new<N: NearestNeighbour>( dataset: ArrayView2<'a, F>, params: &KernelParams<F, N>, ) -> Kernel<F>
Sourcepub fn view(&'a self) -> KernelView<'a, F>
pub fn view(&'a self) -> KernelView<'a, F>
Gives a KernelView which has a view on the original kernel’s inner matrix
Trait Implementations§
Source§impl<K1: Clone + Inner, K2: Clone + Inner> Clone for KernelBase<K1, K2>
impl<K1: Clone + Inner, K2: Clone + Inner> Clone for KernelBase<K1, K2>
Source§fn clone(&self) -> KernelBase<K1, K2>
fn clone(&self) -> KernelBase<K1, K2>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<F: Float, N: NearestNeighbour> Transformer<&ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>>> for KernelParams<F, N>
impl<F: Float, N: NearestNeighbour> Transformer<&ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>>> for KernelParams<F, N>
Source§impl<'a, F: Float, N: NearestNeighbour> Transformer<&ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>>> for KernelParams<F, N>
impl<'a, F: Float, N: NearestNeighbour> Transformer<&ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>>> for KernelParams<F, N>
Source§fn transform(&self, x: &ArrayView2<'a, F>) -> Kernel<F>
fn transform(&self, x: &ArrayView2<'a, F>) -> Kernel<F>
Source§impl<'a, F: Float, N: NearestNeighbour> Transformer<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>>> for KernelParams<F, N>
impl<'a, F: Float, N: NearestNeighbour> Transformer<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize>, Vec<usize>, Vec<F>>>> for KernelParams<F, N>
Source§fn transform(&self, x: ArrayView2<'a, F>) -> Kernel<F>
fn transform(&self, x: ArrayView2<'a, F>) -> Kernel<F>
impl<K1: Inner, K2: Inner> StructuralPartialEq for KernelBase<K1, K2>
Auto Trait Implementations§
impl<K1, K2> Freeze for KernelBase<K1, K2>
impl<K1, K2> RefUnwindSafe for KernelBase<K1, K2>where
<K2 as Inner>::Elem: Sized,
<K1 as Inner>::Elem: Sized + RefUnwindSafe,
K1: RefUnwindSafe,
K2: RefUnwindSafe,
impl<K1, K2> Send for KernelBase<K1, K2>
impl<K1, K2> Sync for KernelBase<K1, K2>
impl<K1, K2> Unpin for KernelBase<K1, K2>
impl<K1, K2> UnwindSafe for KernelBase<K1, K2>where
<K2 as Inner>::Elem: Sized,
<K1 as Inner>::Elem: Sized + UnwindSafe,
K1: UnwindSafe,
K2: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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