diff_priv/analysis/
mse_analyser.rs

1/// Analyses the mean of square errors between the
2/// original data tuple and its anonymized version throughout the
3/// algorithms lifetime
4pub struct MseAnalyser {
5    count: i32,
6    sum_square_erros: f64,
7}
8
9impl MseAnalyser {
10    pub fn add_error(&mut self, square_errors: f64) {
11        self.count += 1;
12        self.sum_square_erros += square_errors
13    }
14
15    pub fn calculate_mse(&self) -> f64 {
16        self.sum_square_erros / self.count as f64
17    }
18}
19
20impl Default for MseAnalyser {
21    fn default() -> Self {
22        Self {
23            count: 0,
24            sum_square_erros: 0.0,
25        }
26    }
27}