Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda