Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AWS AI GO KOTLIN SASS VUE GEN AI CYBERSECURITY DATA SCIENCE
     ❯   

Testing a Perceptron

  • A Perceptron must be Tested and Evaluated
  • A Perceptron must be tested against Real Values.

Test Your Library

Generate new unknown points and check if your Perceptron can guess the right answers:

Example

// 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);
}

Try it Yourself »


Count the Errors

Add a counter to count the number of errors:

Example

// 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++}
}

Try it Yourself »


Tune the Perceptron

How can you tune the Perceptron?

Here are some suggestions:

  • Adjust the learning rate
  • Increase the number of training data
  • Increase the number of training iterations

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2023 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.