Created
February 1, 2022 14:06
-
-
Save doleron/0dc09abeeed1484a8918a8f20f4c6893 to your computer and use it in GitHub Desktop.
Mean Squared Error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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