Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
how to generate classification report using javascript

I'm using ml5 for a classification problem and I'm applying KNN classifier. How do I get the accuracy and the classification report of the model?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Notice the documentation mentions this about classify()'s output:

Object: It returns an object with a top classIndex and label, confidences mapping all class indices to their confidence, and confidencesByLabel mapping all classes' confidence by label.

Bellow there are examples as well, such as the ml5/p5/KNNClassification_Video example.

If you print the result in gotResults() you'll see something like this:

{
    "classIndex": 2,
    "label": "Scissor",
    "confidences": {
        "0": 0.3333333333333333,
        "1": 0,
        "2": 0.6666666666666666
    },
    "confidencesByLabel": {
        "Rock": 0.3333333333333333,
        "Paper": 0,
        "Scissor": 0.6666666666666666
    }
}
  • classIndex will be the index of the top class
  • label is the string associated with that class
  • confidences returns object where the key is the class index and the value is the confidence (as a normalised value (e.g. 0.0 = 0%, 0.5 = 50%, 1.0 = 100%, etc.)
  • confidencesByLabel provides the same confidence values as above, but instead of the class indices the keys are the class labels.

In short, once you call classify(), in the result handler, you're after result.confidences or result.confidencesByLabel depending on your application.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!