pub struct ActiveSampler { /* private fields */ }Expand description
Active sampling strategy for minimising interpolation error.
§Example
use scirs2_interpolate::active_learning::{
ActiveSampler, ActiveSamplerConfig, ActiveAcquisitionFunction,
};
let config = ActiveSamplerConfig {
acquisition: ActiveAcquisitionFunction::MaximumVariance,
n_candidates: 20,
domain: vec![[0.0, 1.0], [0.0, 1.0]],
seed: 7,
};
let mut sampler = ActiveSampler::new(config);
// Seed with one observation
sampler.observe(vec![0.5, 0.5], 1.0);
let next = sampler.suggest_next();
assert_eq!(next.len(), 2);Implementations§
Source§impl ActiveSampler
impl ActiveSampler
Sourcepub fn new(config: ActiveSamplerConfig) -> Self
pub fn new(config: ActiveSamplerConfig) -> Self
Create a new sampler. The number of dimensions is inferred from
config.domain.len().
Sourcepub fn suggest_next(&self) -> Vec<f64>
pub fn suggest_next(&self) -> Vec<f64>
Select the next query point by evaluating the acquisition function at
config.n_candidates randomly sampled candidate points.
If no candidates score above zero, returns the first candidate (random).
Sourcepub fn acquisition_value(&self, point: &[f64]) -> f64
pub fn acquisition_value(&self, point: &[f64]) -> f64
Compute the acquisition value for a single candidate point.
Returns 0.0 when there are no observations.
Sourcepub fn loo_error(&self) -> f64
pub fn loo_error(&self) -> f64
Leave-one-out cross-validation error estimate.
For each observed point, fits a simple GP on the remaining n-1 points and measures the squared prediction error. Returns the RMS LOO error.
Returns 0.0 when fewer than 2 observations are available.
Sourcepub fn n_observed(&self) -> usize
pub fn n_observed(&self) -> usize
Number of observations recorded so far.
Sourcepub fn observed_points(&self) -> &[Vec<f64>]
pub fn observed_points(&self) -> &[Vec<f64>]
Slice of all observed points.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ActiveSampler
impl RefUnwindSafe for ActiveSampler
impl Send for ActiveSampler
impl Sync for ActiveSampler
impl Unpin for ActiveSampler
impl UnsafeUnpin for ActiveSampler
impl UnwindSafe for ActiveSampler
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
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>
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>
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.