Created
September 5, 2019 12:41
-
-
Save kmdupr33/aeacbc7468c7dfe898e4078c45fac8b9 to your computer and use it in GitHub Desktop.
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
fun cost(videoGameData: Array<Pair<Double, Double>>, learningParameters: Pair<Double, Double>): Double = | |
videoGameData.fold(0.0) { acc: Double, pair: Pair<Double, Double> -> | |
val (m, b) = learningParameters | |
val (x, y) = pair | |
acc + ((((m * x) + b) - y).pow(2)/2) | |
} / videoGameData.size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment