Skip to content

Instantly share code, notes, and snippets.

@doleron
Created February 1, 2022 14:06
Show Gist options
  • Select an option

  • Save doleron/0dc09abeeed1484a8918a8f20f4c6893 to your computer and use it in GitHub Desktop.

Select an option

Save doleron/0dc09abeeed1484a8918a8f20f4c6893 to your computer and use it in GitHub Desktop.
Mean Squared Error
function mse(model, data) {
let result = 0.0;
for (let i = 0; i < data.length; ++i) {
const elem = data[i];
const x = elem.x;
const y = elem.y;
const y_hat = predict(x, model);
const diff = y_hat - y;
result += diff * diff;
}
return result / data.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment