Agents
polars_ts.anomaly_agents.agents
Specialized anomaly detection agents and consensus voting.
ZScoreAgent
Detect anomalies via z-score of the last value in a window.
Parameters
threshold Z-score threshold above which a point is flagged.
detect(window)
Score the last value in the window.
Returns
tuple
(z_score, is_anomaly)
RollingStdAgent
Detect anomalies by comparing the last value to a rolling standard deviation.
Parameters
threshold Multiplier of rolling std above which a point is flagged.
detect(window)
Score the last value in the window.
Returns
tuple
(deviation_score, is_anomaly)
MADAgent
Detect anomalies via Median Absolute Deviation (robust to outliers).
Parameters
threshold Modified z-score threshold.
detect(window)
Score the last value using MAD.
Returns
tuple
(modified_z_score, is_anomaly)
ConsensusAgent
Aggregate detection decisions from multiple agents.
Parameters
method
Voting method: "majority", "any", or "weighted".
weights
Per-agent weights for weighted voting. Required when method is
"weighted".
decide(flags, scores)
Aggregate agent flags into a final decision.
Parameters
flags Per-agent anomaly flags. scores Per-agent anomaly scores (used for weighted voting).
Returns
bool Final anomaly decision.