pub struct WeightedSumKernel { /* private fields */ }Expand description
Weighted sum of multiple kernels: K(x,y) = Σ_i w_i * K_i(x,y)
Combines multiple kernels using weighted averaging. Weights should sum to 1.0 for proper normalization.
§Example
use tensorlogic_sklears_kernels::{
LinearKernel, RbfKernel, RbfKernelConfig,
WeightedSumKernel, Kernel
};
let linear = Box::new(LinearKernel::new()) as Box<dyn Kernel>;
let rbf = Box::new(RbfKernel::new(RbfKernelConfig::new(0.5)).unwrap()) as Box<dyn Kernel>;
let weights = vec![0.7, 0.3];
let composite = WeightedSumKernel::new(vec![linear, rbf], weights).unwrap();
let x = vec![1.0, 2.0, 3.0];
let y = vec![4.0, 5.0, 6.0];
let sim = composite.compute(&x, &y).unwrap();
// sim = 0.7 * linear(x,y) + 0.3 * rbf(x,y)Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WeightedSumKernel
impl !RefUnwindSafe for WeightedSumKernel
impl Send for WeightedSumKernel
impl Sync for WeightedSumKernel
impl Unpin for WeightedSumKernel
impl !UnwindSafe for WeightedSumKernel
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> 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