pub struct PredictiveModel { /* private fields */ }Expand description
A predictive model that learns state transitions and rewards from experience.
This model enables an agent to forecast future states, predict rewards, and detect anomalies in its observations.
Implementations§
Source§impl PredictiveModel
impl PredictiveModel
Sourcepub fn new(config: PredictiveConfig) -> Self
pub fn new(config: PredictiveConfig) -> Self
Creates a new PredictiveModel with the given configuration.
Sourcepub fn with_default_config() -> Self
pub fn with_default_config() -> Self
Creates a PredictiveModel with a default configuration.
Sourcepub fn record(&mut self, obs: &Observation)
pub fn record(&mut self, obs: &Observation)
Records an observation, updating the state history and anomaly detector.
Sourcepub fn record_transition(
&mut self,
obs: &Observation,
action: &Action,
reward: f64,
next_obs: &Observation,
)
pub fn record_transition( &mut self, obs: &Observation, action: &Action, reward: f64, next_obs: &Observation, )
Records a full state transition (s, a, r, s').
Sourcepub fn predict_next(
&self,
current: &Observation,
action: &Action,
) -> PredictedState
pub fn predict_next( &self, current: &Observation, action: &Action, ) -> PredictedState
Predicts the next state given the current state and an action.
Sourcepub fn predict_trajectory(
&self,
start: &Observation,
actions: &[Action],
) -> Trajectory
pub fn predict_trajectory( &self, start: &Observation, actions: &[Action], ) -> Trajectory
Predicts a trajectory of future states for a given sequence of actions.
Sourcepub fn predict_reward(&self, state: &Observation, action: &Action) -> f64
pub fn predict_reward(&self, state: &Observation, action: &Action) -> f64
Predicts the expected reward for taking a given action in a given state.
Sourcepub fn is_anomaly(&self, obs: &Observation) -> bool
pub fn is_anomaly(&self, obs: &Observation) -> bool
Returns true if the observation is considered anomalous based on historical data.
Sourcepub fn get_confidence(&self, prediction: &PredictedState) -> f64
pub fn get_confidence(&self, prediction: &PredictedState) -> f64
Returns the confidence score of a PredictedState.
Sourcepub fn get_uncertainty(&self, state: &Observation) -> f64
pub fn get_uncertainty(&self, state: &Observation) -> f64
Returns an estimate of the model’s uncertainty about a given state. This uses the anomaly score as a proxy for uncertainty.
Sourcepub fn history(&self) -> &VecDeque<StateSnapshot>
pub fn history(&self) -> &VecDeque<StateSnapshot>
Returns a reference to the recent history of state snapshots.