Last active
November 12, 2016 06:08
-
-
Save klgraham/36f89627219000290256187604749e5c to your computer and use it in GitHub Desktop.
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
let testData = createData(100) | |
func evaluatePerceptron(p: Perceptron, testData: [PerceptronDataPair]) -> Double { | |
var correct = 0 | |
for d in testData { | |
let prediction = p.feedForward(d.input) | |
if (prediction == d.output) { | |
correct += 1 | |
} | |
} | |
return Double(correct) / Double(testData.count) | |
} | |
evaluatePerceptron(p, testData: testData) | |
let pUntrained = Perceptron(numInputs: 1, offState: -1, bias: 1) | |
evaluatePerceptron(pUntrained, testData: testData) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment