blr-active 0.1.0

Active learning orchestration for Bayesian Linear Regression with Automatic Relevance Determination
Documentation
//! # blr-active: Active Learning Orchestration for Bayesian Linear Regression
//!
//! This crate provides active learning algorithms and orchestration logic for
//! iterative sensor calibration, built on top of the `blr-core` crate's BLR+ARD fitting.
//!
//! `blr-active` implements the 4-phase calibration workflow that drives a BLR+ARD model
//! from an initial rough fit to a precision-targeted, noise-aware calibration.
//!
//! ```text
//! blr-core  (pure math: BLR+ARD, noise estimation, basis functions)
//!     └── blr-active  (this crate: active learning loop, precision tiers, sessions)
//! ```
//!
//! ## Architecture
//!
//! The 4-phase calibration workflow:
//!
//! ```text
//! Phase 0: Noise characterisation
//!   NoiseCalibrationSession → estimate σ_noise → select PrecisionLevel
//!//!//! Phase 1: Exploration
//!   CalibrationSession → collect initial data → fit BLR+ARD
//!//!//! Phase 2: Active learning
//!   CalibrationSession::next_iteration() → recommend sample → user measures → add_measurement()
//!         │  (repeat until precision goal is met or noise floor is hit)
//!//! Phase 3: Convergence / completion
//!   CalibrationSession → export_history_json() → store results
//! ```
//!
//! ## Modules
//!
//! - [`active_learning`] — 5 active learning algorithms (variance, mutual info, goal-based, etc.)
//! - [`calibration_session`] — User-facing noise-aware precision targeting session ([`NoiseCalibrationSession`])
//! - [`goal_assessment`] — Feasibility classification for precision goals ([`assess_goal_feasibility`])
//! - [`precision_tiers`] — Precision tier definitions (Low/Moderate/High/Max) ([`PrecisionLevel`])
//! - [`error`] — [`ALError`] type with `From<BLRError>` bridge
//!
//! **Note:** Certificate metadata is in `sensor-calibration-component` (application layer).
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use blr_active::{NoiseCalibrationSession, CalibrationSession, SessionConfig};
//! use blr_core::noise_estimation::{NoiseEstimate, SensorType};
//!
//! // Phase 0: characterise sensor noise from initial measurements
//! let noise_est = NoiseEstimate {
//!     point_estimate: 0.03,
//!     lower_bound: 0.027,
//!     upper_bound: 0.033,
//!     confidence: "stable".to_string(),
//! };
//! let mut noise_session = NoiseCalibrationSession::new(SensorType::Hall, noise_est);
//!
//! // Inspect precision tiers to choose a goal
//! for tier in noise_session.precision_tiers.iter() {
//!     println!("{:?}: target std = {:.4}", tier.level, tier.absolute_tolerance);
//! }
//!
//! // Phase 1-3: active learning loop
//! let config = SessionConfig::default();
//! let mut session = CalibrationSession::new(config, |x: f64| vec![1.0, x], 2);
//! // ... add measurements, call next_iteration(), check IterationOutcome
//! ```
//!
//! ## Feature Flags
//!
//! | Feature | Default | Description |
//! |---------|---------|-------------|
//! | `std`   | ✓       | Enable standard library support (required for blr-core) |
//!
//! ## References
//!
//! - Settles, B. (2009). "Active Learning Literature Survey."
//!   University of Wisconsin–Madison, Technical Report 1648.
//! - MacKay, D. J. C. (1992). "Information-Based Objective Functions for Active Data Selection."
//!   *Neural Computation*, 4(4), 590–604.

pub mod active_learning;
pub mod calibration_session;
pub mod error;
pub mod goal_assessment;
pub mod precision_tiers;

pub use active_learning::acquisition::RecommendedSample;
pub use active_learning::noise_floor::{
    detect_noise_floor, detect_noise_floor_default, NoiseFloorConfig, NoiseFloorDiagnostic,
};
pub use active_learning::orchestration::{
    CalibrationSession, IterationOutcome, PrecisionRecord, SampleRecord, SessionConfig,
};
pub use active_learning::precision::{
    assess_precision, percentile, PrecisionAssessment, PrecisionStatus,
};
pub use active_learning::variance::{posterior_std, posterior_std_grid, posterior_variance};
pub use calibration_session::{ActiveLearningConfig, NoiseCalibrationSession};
pub use error::{ALError, ALResult};
pub use goal_assessment::{assess_goal_feasibility, CalibrationGoal, GoalFeasibility};
pub use precision_tiers::{
    compute_precision_tiers, Feasibility, PrecisionLevel, PrecisionTierInfo,
};