pub struct AutoKernelGp { /* private fields */ }Expand description
Gaussian Process interpolator with automatic kernel structure discovery.
§Example
use scirs2_interpolate::auto_kernel_gp::{AutoKernelGp, AutoKernelGpConfig};
let x: Vec<f64> = (0..20).map(|i| i as f64 * std::f64::consts::PI / 10.0).collect();
let y: Vec<f64> = x.iter().map(|&xi| xi.sin()).collect();
let config = AutoKernelGpConfig {
max_depth: 1,
cv_folds: 3,
..Default::default()
};
let mut gp = AutoKernelGp::new(config);
gp.fit(&x, &y).expect("fit ok");
let x_new = vec![0.1, 0.5, 1.0];
let preds = gp.predict(&x_new).expect("predict ok");
assert_eq!(preds.len(), 3);Implementations§
Source§impl AutoKernelGp
impl AutoKernelGp
Sourcepub fn new(config: AutoKernelGpConfig) -> Self
pub fn new(config: AutoKernelGpConfig) -> Self
Create a new (unfitted) AutoKernelGp.
Sourcepub fn fit(&mut self, x: &[f64], y: &[f64]) -> InterpolateResult<()>
pub fn fit(&mut self, x: &[f64], y: &[f64]) -> InterpolateResult<()>
Search the kernel grammar and fit the GP on x, y.
x must be strictly sorted (ascending) for well-defined kernel matrices,
though this is not enforced. Duplicate x values will cause a
near-singular kernel matrix which is handled by jitter.
Sourcepub fn predict(&self, x_new: &[f64]) -> InterpolateResult<Vec<f64>>
pub fn predict(&self, x_new: &[f64]) -> InterpolateResult<Vec<f64>>
Predict at new input locations x_new.
Sourcepub fn selected_kernel_description(&self) -> String
pub fn selected_kernel_description(&self) -> String
Return a human-readable description of the selected kernel structure.
Sourcepub fn best_cv_score(&self) -> f64
pub fn best_cv_score(&self) -> f64
Return the best cross-validation score (lower is better).
Sourcepub fn kernel_search_results(&self) -> &[(String, f64)]
pub fn kernel_search_results(&self) -> &[(String, f64)]
Return the full ranked list of (kernel_description, cv_mse_score) pairs.
Sorted by CV-MSE ascending (best first).
Sourcepub fn kernel(&self) -> &KernelExpr
pub fn kernel(&self) -> &KernelExpr
Return the selected kernel expression.
Auto Trait Implementations§
impl Freeze for AutoKernelGp
impl RefUnwindSafe for AutoKernelGp
impl Send for AutoKernelGp
impl Sync for AutoKernelGp
impl Unpin for AutoKernelGp
impl UnsafeUnpin for AutoKernelGp
impl UnwindSafe for AutoKernelGp
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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.