augurs_prophet/error.rs
1use crate::TimestampSeconds;
2
3/// Errors that can occur when using the Prophet forecasting algorithm.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum Error {
7 /// The data provided had mismatched column lengths.
8 #[error("Mismatched column lengths: {a_name} has length {a} but {b_name} has length {b}")]
9 MismatchedLengths {
10 /// The length of the first column.
11 a: usize,
12 /// The length of the second column.
13 b: usize,
14 /// The name of the first column.
15 a_name: String,
16 /// The name of the second column.
17 b_name: String,
18 },
19 /// Not enough data was provided to fit the model.
20 #[error("Not enough data")]
21 NotEnoughData,
22 /// Optimization failed for some reason.
23 #[error("Optimization failed: {0}")]
24 OptimizationFailed(String),
25 /// An invalid interval width was passed.
26 ///
27 /// The interval width must be between 0.0 and 1.0.
28 #[error("Invalid interval width: {0}; must be between 0.0 and 1.0")]
29 InvalidIntervalWidth(f64),
30 /// Too many data points were provided, overflowing an `i32`.
31 #[error("Too many data points: {got}, max is {max}", got = .0, max = i32::MAX)]
32 TooManyDataPoints(usize),
33 /// The timestamps provided are constant.
34 #[error("Timestamps are constant: {0}")]
35 TimestampsAreConstant(TimestampSeconds),
36 /// The same seasonality was added to the model twice.
37 #[error("Attempted to add a seasonality with the same name: {0}")]
38 DuplicateSeasonality(String),
39 /// A column contained an infinite value.
40 #[error("Found infinite value in column {column}")]
41 InfiniteValue {
42 /// The name of the column that contained an infinite value.
43 column: String,
44 },
45 /// A column contained a NaN value.
46 #[error("Found NaN value in column {column}")]
47 NaNValue {
48 /// The name of the column that contained a NaN value.
49 column: String,
50 },
51 /// A regressor was added to the model but missing from the data.
52 #[error("Missing regressor: {0}")]
53 MissingRegressor(String),
54 /// A seasonality in the model was marked as conditional but
55 /// the condition column was missing from the data.
56 #[error("Missing condition for seasonality: {0}")]
57 MissingSeasonalityCondition(String),
58 /// AbsMax scaling failed because the min and max were the same.
59 #[error("AbsMax scaling failed because the min and max were the same")]
60 AbsMaxScalingFailed,
61 /// The `cap` column for logistic growth was missing.
62 #[error("Missing cap for logistic growth")]
63 MissingCap,
64 /// The `floor` column for logistic growth was missing.
65 #[error("Missing floor for logistic growth")]
66 MissingFloor,
67 /// The cap was not always greater than the floor.
68 #[error("Cap is not greater than floor (which defaults to 0)")]
69 CapNotGreaterThanFloor,
70 /// One or more of the provided changepoints were out
71 /// of the range of the training data.
72 #[error("Changepoints must fall within training data")]
73 ChangepointsOutOfRange,
74 /// The Prophet model has not yet been fit.
75 ///
76 /// Fit the model first using [`Prophet::fit`](crate::Prophet::fit).
77 #[error("Model has not been fit")]
78 ModelNotFit,
79 /// It was not possible to infer the frequency of the dates.
80 ///
81 /// This can happen if the dates are not evenly spaced, and
82 /// there is no frequency that appears more often than others.
83 #[error("Unable to infer frequency from dates: {0:?}")]
84 UnableToInferFrequency(Vec<TimestampSeconds>),
85}