Created
February 26, 2019 19:46
-
-
Save trygvea/9b01810bc6abb8c9643289002a52f3b5 to your computer and use it in GitHub Desktop.
Machine learning - pedagogical
This file contains 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
type Data = number[] | |
type Observation = number | |
type Prediction = Observation | |
function learn(xs: Data[], ys: Observation[]) { | |
return (x: Data): Prediction => { | |
// use xs and ys to predict outcome of x | |
return 1 | |
} | |
} | |
const data = [ | |
[1, 2, 3, 4, 5], | |
[2, 5, 1, 9, 4], | |
[9, 4, 3, 2, 5], | |
// ...more | |
] | |
const observations = [ | |
5, | |
6, | |
9, | |
// ...more | |
] | |
const predict = learn(data, observations) | |
predict([1, 3, 1, 5, 4]) // => 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment