Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda