chronix_analytics/forecast/error.rs
1//! Forecast errors.
2
3/// Errors from forecast operations.
4#[derive(Debug, thiserror::Error)]
5pub enum ForecastError {
6 /// The input time-series has fewer observations than the model requires.
7 #[error("insufficient data: need at least {min} points, got {got}")]
8 InsufficientData {
9 /// Minimum number of data points required.
10 min: usize,
11 /// Number of data points actually provided.
12 got: usize,
13 },
14
15 /// A user-supplied parameter or input is invalid.
16 #[error("invalid input: {0}")]
17 InvalidInput(String),
18
19 /// The optimiser did not converge within the iteration limit.
20 #[error("convergence failed after {iterations} iterations")]
21 ConvergenceFailed {
22 /// Number of iterations completed before giving up.
23 iterations: usize,
24 },
25
26 /// A model hyper-parameter has an invalid value.
27 #[error("invalid parameter: {name} = {value} — {reason}")]
28 InvalidParams {
29 /// Name of the invalid parameter.
30 name: &'static str,
31 /// The invalid value that was supplied.
32 value: String,
33 /// Human-readable explanation of why the value is rejected.
34 reason: &'static str,
35 },
36
37 /// A computation produced NaN / Inf or similar numeric failure.
38 #[error("numerical instability: {0}")]
39 NumericalInstability(String),
40
41 /// The model has not been fitted yet.
42 #[error("model not fitted — call fit() before predict()")]
43 NotFitted,
44
45 /// An error forwarded from the compute engine.
46 #[error("compute error: {0}")]
47 Compute(#[from] crate::compute::ComputeError),
48}