MCPcopy Create free account
hub / github.com/daniel-e/rustml / error

Method error

src/regression.rs:126–131  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

mul_vec_minus_vecMethod · 0.80
rowsMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected