Skip to main content

CalibrationSession

Struct CalibrationSession 

Source
pub struct CalibrationSession {
    pub config: SessionConfig,
    pub samples: Vec<SampleRecord>,
    pub precision_history: Vec<PrecisionRecord>,
    pub iteration: usize,
    /* private fields */
}
Expand description

An active calibration session tracking model, samples, and history.

Fields§

§config: SessionConfig

Session configuration.

§samples: Vec<SampleRecord>

All measurements collected so far.

§precision_history: Vec<PrecisionRecord>

Precision snapshots from each completed iteration.

§iteration: usize

Current iteration count (0-based).

Implementations§

Source§

impl CalibrationSession

Source

pub fn new( config: SessionConfig, feature_fn: impl Fn(f64) -> Vec<f64> + 'static, feature_dim: usize, ) -> Self

Create a new calibration session.

§Arguments
  • config: session configuration
  • feature_fn: maps scalar input → feature vector (must have length feature_dim)
  • feature_dim: number of features D
Source

pub fn add_measurement(&mut self, raw_input: f64, measured_output: f64)

Add a new measurement from the user/sensor.

Source

pub fn add_measurements(&mut self, inputs: &[f64], outputs: &[f64])

Add multiple measurements at once.

Source

pub fn sample_count(&self) -> usize

Number of samples currently in the session.

Source

pub fn next_iteration(&mut self) -> IterationOutcome

Run one iteration of the calibration state machine.

Returns an IterationOutcome indicating what to do next. The caller should add new measurements (at the recommended locations) before calling this again.

Source

pub fn export_history_json(&self) -> String

Export the calibration history as a JSON string.

Schema:

{
  "iteration_count": <usize>,
  "sample_count": <usize>,
  "target_precision": <f64>,
  "precision_history": [
    { "iteration": .., "sample_count": .., "mean_std": .., "max_std": ..,
      "p95_std": .., "goal_met": .. },
    ...
  ],
  "samples": [
    { "raw_input": .., "measured_output": .., "added_at_iteration": .. },
    ...
  ]
}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.