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
pub mod knn;
pub mod knn_utils;
pub mod nn_bound;
pub mod frequentist;
pub mod convergence;
pub use self::knn::KNNEstimator;
pub use self::nn_bound::NNBoundEstimator;
pub use self::frequentist::FrequentistEstimator;
pub use self::convergence::ForwardChecker;
pub use self::knn_utils::*;
use crate::Label;
use ndarray::prelude::*;
#[derive(Deserialize)]
#[serde(rename_all="lowercase")]
pub enum Estimate {
NN,
KNN,
Frequentist,
#[serde(rename="nn-bound")]
NNBound,
}
pub trait BayesEstimator {
fn add_example(&mut self, x: &ArrayView1<f64>, y: Label) -> Result<(), ()>;
fn get_error_count(&self) -> usize;
fn get_error(&self) -> f64;
fn get_individual_errors(&self) -> Vec<bool>;
}
fn some_or_error<T>(opt: Option<T>) -> Result<T, ()> {
match opt {
Some(x) => Ok(x),
None => Err(()),
}
}