Generate new unknown points and check if your Perceptron can guess the right answers:
// Test Against Unknown Data
const counter = 500;
for (let i = 0; i < counter; i++) {
let x = Math.random() * xMax;
let y = Math.random() * yMax;
let guess = ptron.activate([x, y, ptron.bias]);
let color = "black";
if (guess == 0) color = "blue";
plotter.plotPoint(x, y, color);
}
Add a counter to count the number of errors:
// Test Against Unknown Data
const counter = 500;
let errors = 0;
for (let i = 0; i < counter; i++) {
let x = Math.random() * xMax;
let y = Math.random() * yMax;
let guess = ptron.activate([x, y, ptron.bias]);
let color = "black";
if (guess == 0) color = "blue";
plotter.plotPoint(x, y, color);
if ((y > f(x) && guess == 0) || (y < f(x) && guess == 1)) {errors++}
}
How can you tune the Perceptron?
Here are some suggestions:
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!