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

144
Views
MAPE calculation in Javascript

I need a function in javascript to calculate MAPE. (Mean absolute percentage error) I do not want to depend on an external library and just want a vanilla javascript version of the solution.

there are quite some sample solutions in other programming language, and it would be great if someone can convert it to javascript for the use in javascript.

Formula for MAPE:

enter image description here

where f_i is the forecast value and a_i is the actual value.

NOTE: that i want to achieve this w/o the use of a library, since there is one library available out there, but i feel this can be achieved without the use of a library.

  • https://github.com/stdlib-js/stats-incr-mape

Some examples of MAPE in other programming languages:

  • How to optimize MAPE code in Python?
  • https://www.geeksforgeeks.org/how-to-calculate-mape-in-r/

If you can write out the code in javascript, that will really help me out, since i need to use this formula.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

function MAPE(f, a) {
 n = a.length
 if (f.length != n) throw new Error(‘f must have the same length as a!’)
 sum = 0
 for (i = 0; i < n; ++i) sum += Math.abs((a[i] - f[i])/a[i])
 return (100/n)*sum
}
about 4 years ago · Santiago Gelvez 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!