Struct linfa_kernel::KernelParams [−][src]
pub struct KernelParams<F> { /* fields omitted */ }Defines the set of parameters needed to build a kernel
Implementations
impl<F: Float> KernelParams<F>[src]
impl<F: Float> KernelParams<F>[src]pub fn method(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(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<F: Float> Transformer<&'_ ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>> for KernelParams<F>[src]
impl<F: Float> Transformer<&'_ ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>> for KernelParams<F>[src]fn transform(&self, x: &Array2<F>) -> Kernel<F>[src]
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
impl<'a, F: Float> Transformer<&'_ ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>> for KernelParams<F>[src]
impl<'a, F: Float> Transformer<&'_ ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>> for KernelParams<F>[src]fn transform(&self, x: &ArrayView2<'a, F>) -> Kernel<F>[src]
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
impl<'a, F: Float, L: 'a, T: AsTargets<Elem = L> + FromTargetArray<'a, L>> Transformer<&'a DatasetBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, T>, DatasetBase<KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>, <T as FromTargetArray<'a, L>>::View>> for KernelParams<F>[src]
impl<'a, F: Float, L: 'a, T: AsTargets<Elem = L> + FromTargetArray<'a, L>> Transformer<&'a DatasetBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, T>, DatasetBase<KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>, <T as FromTargetArray<'a, L>>::View>> for KernelParams<F>[src]fn transform(
&self,
x: &'a DatasetBase<Array2<F>, T>
) -> DatasetBase<Kernel<F>, T::View>[src]
&self,
x: &'a DatasetBase<Array2<F>, T>
) -> DatasetBase<Kernel<F>, T::View>
Builds a new Dataset with the kernel as the records and the same targets as the input one.
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, 'b, F: Float, L: 'b, T: AsTargets<Elem = L> + FromTargetArray<'b, L>> Transformer<&'b DatasetBase<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, T>, DatasetBase<KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>, <T as FromTargetArray<'b, L>>::View>> for KernelParams<F>[src]
impl<'a, 'b, F: Float, L: 'b, T: AsTargets<Elem = L> + FromTargetArray<'b, L>> Transformer<&'b DatasetBase<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, T>, DatasetBase<KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>, <T as FromTargetArray<'b, L>>::View>> for KernelParams<F>[src]fn transform(
&self,
x: &'b DatasetBase<ArrayView2<'a, F>, T>
) -> DatasetBase<Kernel<F>, T::View>[src]
&self,
x: &'b DatasetBase<ArrayView2<'a, F>, T>
) -> DatasetBase<Kernel<F>, T::View>
Builds a new Dataset with the kernel as the records and the same targets as the input one.
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]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>> for KernelParams<F>[src]
impl<'a, F: Float> Transformer<ArrayBase<ViewRepr<&'a F>, Dim<[usize; 2]>>, KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>> for KernelParams<F>[src]fn transform(&self, x: ArrayView2<'a, F>) -> Kernel<F>[src]
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
impl<'a, F: Float, T: AsTargets> Transformer<DatasetBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, T>, DatasetBase<KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>, T>> for KernelParams<F>[src]
impl<'a, F: Float, T: AsTargets> Transformer<DatasetBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, T>, DatasetBase<KernelBase<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CsMatBase<F, usize, Vec<usize, Global>, Vec<usize, Global>, Vec<F, Global>, usize>>, T>> for KernelParams<F>[src]fn transform(&self, x: DatasetBase<Array2<F>, T>) -> DatasetBase<Kernel<F>, T>[src]
Builds a new Dataset with the kernel as the records and the same targets as the input one.
It takes ownership of the original dataset.
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
Auto Trait Implementations
impl<F> RefUnwindSafe for KernelParams<F> where
F: RefUnwindSafe,
impl<F> RefUnwindSafe for KernelParams<F> where
F: RefUnwindSafe, impl<F> Send for KernelParams<F> where
F: Send,
impl<F> Send for KernelParams<F> where
F: Send, impl<F> Sync for KernelParams<F> where
F: Sync,
impl<F> Sync for KernelParams<F> where
F: Sync, impl<F> Unpin for KernelParams<F> where
F: Unpin,
impl<F> Unpin for KernelParams<F> where
F: Unpin, impl<F> UnwindSafe for KernelParams<F> where
F: UnwindSafe,
impl<F> UnwindSafe for KernelParams<F> where
F: UnwindSafe,