feat: adds e-SVR

This commit is contained in:
Volodymyr Orlov
2020-10-15 16:23:26 -07:00
parent bb96354363
commit 20e58a8817
8 changed files with 719 additions and 2 deletions
+25
View File
@@ -0,0 +1,25 @@
//! # Support Vector Machines
//!
pub mod svr;
use serde::{Deserialize, Serialize};
use crate::linalg::BaseVector;
use crate::math::num::RealNumber;
/// Kernel
pub trait Kernel<T: RealNumber, V: BaseVector<T>> {
/// Apply kernel function to x_i and x_j
fn apply(&self, x_i: &V, x_j: &V) -> T;
}
/// Linear Kernel
#[derive(Serialize, Deserialize, Debug)]
pub struct LinearKernel {}
impl<T: RealNumber, V: BaseVector<T>> Kernel<T, V> for LinearKernel {
fn apply(&self, x_i: &V, x_j: &V) -> T {
x_i.dot(x_j)
}
}