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