[][src]Struct linfa_kernel::KernelParams

pub struct KernelParams<F> { /* fields omitted */ }

Defines the set of prameters needed to build a kernel

Implementations

impl<F: Float> KernelParams<F>[src]

pub fn method(mut self: Self, method: KernelMethod<F>) -> KernelParams<F>[src]

Setter for method. Can be chained with kind and transform.

Arguments

  • method: The inner product that will be used by the kernel

Returns

The modified set of params

Example

use linfa_kernel::{Kernel, KernelMethod};
use linfa::traits::Transformer;
use ndarray::Array2;

let data = Array2::from_shape_vec((3,2), vec![1., 2., 3., 4., 5., 6.,]).unwrap();

// Build a kernel from `data` with the defaul parameters
// and then set the preferred method
let params = Kernel::params().method(KernelMethod::Linear);
let kernel = params.transform(&data);

pub fn kind(mut self: Self, kind: KernelType) -> KernelParams<F>[src]

Setter for kind. Can be chained with method and transform.

Arguments

  • kind: The kind of kernel to build, either dense or sparse

Returns

The modified set of params

Example

use linfa_kernel::{Kernel, KernelType};
use linfa::traits::Transformer;
use ndarray::Array2;

let data = Array2::from_shape_vec((3,2), vec![1., 2., 3., 4., 5., 6.,]).unwrap();

// Build a kernel from `data` with the defaul parameters
// and then set the preferred kind
let params = Kernel::params().kind(KernelType::Dense);
let kernel = params.transform(&data);

Trait Implementations

impl<'a, F: Float> Transformer<&'a ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, Kernel<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>>> for KernelParams<F>[src]

pub fn transform(&self, x: &'a Array2<F>) -> Kernel<ArrayView2<'a, F>>[src]

Builds a kernel from the input data without copying it.

A reference to the input data will be kept by the kernel through an ArrayView

Parameters

  • x: matrix of records (##records, ##features) in input

Returns

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

impl<'a, F: Float, T: Targets> Transformer<&'a DatasetBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, T>, DatasetBase<Kernel<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>>, &'a T>> for KernelParams<F>[src]

pub fn transform(
    &self,
    x: &'a DatasetBase<Array2<F>, T>
) -> DatasetBase<Kernel<ArrayView2<'a, F>>, &'a T>
[src]

Builds a new Dataset with the kernel as the records and the same targets as the input one.

A reference to the input records will be kept by the kernel through an ArrayView

Parameters

  • x: A dataset with a matrix of records (##records, ##features) and any targets

Returns

A new dataset with:

  • records: a kernel build from x.records() according to the parameters on which this method is called
  • targets: same as x.targets()

Panics

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

impl<'a, F: Float, T: Targets> Transformer<&'a DatasetBase<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, T>, DatasetBase<Kernel<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>>, &'a [<T as Targets>::Elem]>> for KernelParams<F>[src]

pub fn transform(
    &self,
    x: &'a DatasetBase<ArrayView2<'a, F>, T>
) -> DatasetBase<Kernel<ArrayView2<'a, F>>, &'a [T::Elem]>
[src]

Builds a new Dataset with the kernel as the records and the same targets as the input one.

A reference to the input records will be kept by the kernel through an ArrayView

Parameters

  • x: A dataset with a matrix of records (##records, ##features) and any targets

Returns

A new dataset with:

  • records: a kernel build from x.records() according to the parameters on which this method is called
  • targets: a slice of x.targets()

Panics

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

impl<'a, F: Float> Transformer<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, Kernel<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>>> for KernelParams<F>[src]

pub fn transform(&self, x: ArrayView2<'a, F>) -> Kernel<ArrayView2<'a, F>>[src]

Builds a kernel from a view of the input data.

A reference to the input data will be kept by the kernel through an ArrayView

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

impl<F> RefUnwindSafe for KernelParams<F> where
    F: RefUnwindSafe
[src]

impl<F> Send for KernelParams<F> where
    F: Send
[src]

impl<F> Sync for KernelParams<F> where
    F: Sync
[src]

impl<F> Unpin for KernelParams<F> where
    F: Unpin
[src]

impl<F> UnwindSafe for KernelParams<F> where
    F: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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