pub struct KernelBase<K1: Inner, K2: Inner> where
    K1::Elem: Float,
    K2::Elem: Float
{ 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

Whether the kernel is a linear kernel

Returns
  • true: if the kernel is linear
  • false: otherwise

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

Generate parameters with a specific nearest neighbour algorithm

Performs the matrix product between the kernel matrix and the input

Parameters
  • rhs: The matrix on the right-hand side of the multiplication
Returns

A new matrix containing the matrix product between the kernel and rhs

Panics

If the shapes of kernel and rhs are not compatible for multiplication

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

Gives the size of the side of the square kernel matrix

Getter for a column of the kernel matrix

Params
  • i: the index of the column
Returns

The i-th column of the kernel matrix, stored as a Vec

Panics

If i is out of bounds

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

Getter for the elements in the diagonal of the kernel matrix

Returns

A new array containing the copy of all elements in the diagonal fo the kernel matrix

Gives a KernelView which has a view on the original kernel’s inner matrix

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Builds a kernel from a view of the input data.

Parameters
  • x: view of a matrix of records (#records, #features)

A kernel build from x according to the parameters on which this method is called

Panics

If the kernel type is Sparse and the number of neighbors specified is not between 1 and #records-1

Builds a kernel from a view of the input data.

Parameters
  • x: view of a matrix of records (#records, #features)

A kernel build from x according to the parameters on which this method is called

Panics

If the kernel type is Sparse and the number of neighbors specified is not between 1 and #records-1

Builds a kernel from a view of the input data.

Parameters
  • x: view of a matrix of records (#records, #features)

A kernel build from x according to the parameters on which this method is called

Panics

If the kernel type is Sparse and the number of neighbors specified is not between 1 and #records-1

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.