pub struct Point {
pub horizon: usize,
pub mean: f64,
pub intervals: Vec<Interval>,
}Expand description
A forecast with its intervals.
Fields§
§horizon: usizePeriods ahead (for a cumulative forecast, how many were added up).
mean: f64§intervals: Vec<Interval>Implementations§
Source§impl Point
impl Point
Sourcepub fn interval(&self, level: f64) -> Option<Interval>
pub fn interval(&self, level: f64) -> Option<Interval>
The interval with the given coverage, if it was asked for.
Examples found in repository?
examples/piaui.rs (line 43)
9fn main() {
10 let data = include_str!("../data/piaui_revenue.csv");
11 let rows: Vec<Vec<f64>> = data
12 .lines()
13 .filter(|l| !l.starts_with('#') && !l.starts_with("month"))
14 .map(|l| l.split(',').skip(1).map(|v| v.parse().unwrap()).collect())
15 .collect();
16
17 for (column, name) in [(0, "ICMS"), (1, "FPE")] {
18 let values: Vec<f64> = rows.iter().map(|r| r[column]).collect();
19 // the first observation is March 2017
20 let y = Series::monthly(&values, 2);
21 let report = Backtest::default()
22 .run(y, &models::thorough())
23 .expect("series long enough");
24
25 println!(
26 "\n{name}: {} origins, {} months ahead",
27 report.origins, report.horizon
28 );
29 let mut ranking: Vec<_> = report.candidates.iter().collect();
30 ranking.sort_by(|a, b| a.score.total_cmp(&b.score));
31 for c in ranking {
32 let h = |i: usize| c.horizons[i].mape.unwrap_or(f64::NAN);
33 println!(
34 " {:<45} MAPE {:5.2}% h=1 {:5.2}% h=12 {:5.2}%",
35 c.name,
36 c.score,
37 h(0),
38 h(11)
39 );
40 }
41 let best = report.chosen();
42 let half = best.cumulative(6).expect("six months");
43 let i = half.interval(0.80).expect("80% interval");
44 println!(
45 " next 6 months with {}: {:.2} bi (80%: {:.2} to {:.2})",
46 best.name,
47 half.mean / 1e9,
48 i.lower / 1e9,
49 i.upper / 1e9
50 );
51 }
52}Trait Implementations§
impl StructuralPartialEq for Point
Auto Trait Implementations§
impl Freeze for Point
impl RefUnwindSafe for Point
impl Send for Point
impl Sync for Point
impl Unpin for Point
impl UnsafeUnpin for Point
impl UnwindSafe for Point
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more