All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.metarank.ltrlib.metric.MSE.scala Maven / Gradle / Ivy

There is a newer version: 0.2.6
Show newest version
package io.github.metarank.ltrlib.metric

import io.github.metarank.cfor._

object MSE extends Metric {
  def eval(y: Array[Array[Double]], yhat: Array[Array[Double]]): Double = {
    var sum = 0.0
    var cnt = 0
    cfor(y.indices) { i =>
      cfor(y(i).indices) { j =>
        {
          sum += (y(i)(j) - yhat(i)(j)) * (y(i)(j) - yhat(i)(j))
          cnt += 1
        }
      }

    }
    sum / cnt
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy