Computes the error of the hypothesis for the examples in the design matrix `x` and the target values `y`. $$\frac{1}{m}(X\theta-y)\^T(X\theta-y)$$
(&self, x: &Matrix<f64>, y: &[f64])
| 124 | /// |
| 125 | /// $$\frac{1}{m}(X\theta-y)\^T(X\theta-y)$$ |
| 126 | pub fn error(&self, x: &Matrix<f64>, y: &[f64]) -> f64 { |
| 127 | |
| 128 | x.mul_vec_minus_vec(&self.thetas, y) |
| 129 | .iter() |
| 130 | .fold(0.0, |acc, &x| acc + x*x) / 2.0 / (x.rows() as f64) |
| 131 | } |
| 132 | |
| 133 | pub fn derivatives(&self, x: &Matrix<f64>, y: &[f64]) -> Vec<f64> { |
| 134 |
nothing calls this directly
no test coverage detected