r/ml/
common.rs

1//!
2//! This package contains some common structs and functions
3//!
4
5pub struct DataSet<X, Y> (Vec<(Vec<X>, Y)>);
6
7impl<X, Y> DataSet<X, Y> {
8    /// init a new dataset
9    pub fn new() -> DataSet<X, Y> {
10        DataSet(Vec::new())
11    }
12
13    #[inline]
14    pub fn ds(&mut self) -> &Vec<(Vec<X>, Y)> {
15        &self.0
16    }
17
18    pub fn at(&mut self, i: usize) -> &(Vec<X>, Y) {
19        &self.0[i]
20    }
21
22    pub fn x_at(&mut self, i: usize) -> &Vec<X> {
23        &self.0[i].0
24    }
25
26    pub fn y_at(&mut self, i: usize) -> &Y {
27        &self.0[i].1
28    }
29}