pub struct GaussianKernel {
pub sigma: f32,
}Expand description
Gaussian kernel, defined as $\exp(-\frac{||x_1 - x_2||^2}{2\sigma^2})$. Also known as RBF kernel.
§Examples
use pr_ml::{RowVector, svm::{Kernel, GaussianKernel}};
let kernel = GaussianKernel::new(1.0);
let x1 = RowVector::from([1.0, 2.0]);
let x2 = RowVector::from([2.0, 3.0]);
let result = kernel.compute(&x1, &x2);
assert!((result - 0.3679).abs() < 1e-4); // exp(-1) = 0.3679Fields§
§sigma: f32Standard deviation parameter.
Implementations§
Source§impl GaussianKernel
impl GaussianKernel
Sourcepub fn new(sigma: f32) -> Self
pub fn new(sigma: f32) -> Self
Creates a new GaussianKernel with the given sigma.
Trait Implementations§
Source§impl Clone for GaussianKernel
impl Clone for GaussianKernel
Source§fn clone(&self) -> GaussianKernel
fn clone(&self) -> GaussianKernel
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 Debug for GaussianKernel
impl Debug for GaussianKernel
Source§impl Default for GaussianKernel
impl Default for GaussianKernel
Source§impl<const D: usize> Kernel<D> for GaussianKernel
impl<const D: usize> Kernel<D> for GaussianKernel
Source§impl PartialEq for GaussianKernel
impl PartialEq for GaussianKernel
impl Copy for GaussianKernel
impl StructuralPartialEq for GaussianKernel
Auto Trait Implementations§
impl Freeze for GaussianKernel
impl RefUnwindSafe for GaussianKernel
impl Send for GaussianKernel
impl Sync for GaussianKernel
impl Unpin for GaussianKernel
impl UnwindSafe for GaussianKernel
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.