<commit_before>package ml.dmlc.mxnet

abstract class EvalMetric(protected val name: String) {

  protected var numInst: Int = 0
  protected var sumMetric: Float = 0.0f

  def update(labels: NDArray, preds: NDArray): Unit

  def reset: Unit = {
    this.numInst = 0
    this.sumMetric = 0.0f
  }

  def get: (String, Float) = {
    (this.name, this.sumMetric / this.numInst)
  }
}

class Accuracy extends EvalMetric("accuracy") {
  def update(labels: NDArray, preds: NDArray): Unit = {

    require(labels.size == preds.size, "labels and predictions should have the same length.")

    (0 to preds.size) foreach (i => {
      val pred: NDArray = preds.slice(i, i)
      val label: NDArray = labels.slice(i, i)
      val predLabel = pred.toArray.max

//      require(label.shape(0) < predLabel.shape(0), "Should not have more predict labels than actual labels ")
//      this.sumMetric += predLabel == label
    })
  }
}





<commit_msg>metrics: MAE and RMSE (WIP)<commit_after>package ml.dmlc.mxnet

abstract class EvalMetric(protected val name: String) {

  protected var numInst: Int = 0
  protected var sumMetric: Float = 0.0f

  def update(labels: NDArray, preds: NDArray): Unit

  def reset: Unit = {
    this.numInst = 0
    this.sumMetric = 0.0f
  }

  def get: (String, Float) = {
    (this.name, this.sumMetric / this.numInst)
  }
}

class Accuracy extends EvalMetric("accuracy") {
  def update(labels: NDArray, preds: NDArray): Unit = {

    require(labels.size == preds.size, "labels and predictions should have the same length.")

    (0 to preds.size) foreach (i => {
      val pred: NDArray = preds.slice(i, i)
      val label: NDArray = labels.slice(i, i)

//      require(label.shape(0) < predLabel.shape(0), "Should not have more predict labels than actual labels ")
    })
  }
}

class MAE extends EvalMetric("mae") {
  def update(labels: NDArray, preds: NDArray): Unit = {

    require(labels.size == preds.size, "labels and predictions should have the same length.")

    for ( (label, pred) <- (labels.toArray zip preds.toArray)) {

    }
  }
}


class RMSE extends EvalMetric("rmse") {
  def update(labels: NDArray, preds: NDArray): Unit = {

    require(labels.size == preds.size, "labels and predictions should have the same length.")

    for ( (label, pred) <- (labels.toArray zip preds.toArray)) {

    }
  }
}








{'fraction_non_alphanumeric': 0.12665245202558637, 'fraction_numerical': 0.00767590618336887, 'mean_word_length': 3.1448763250883394, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2652673', 'n_tokens_mistral': 824, 'n_tokens_neox': 762, 'n_words': 230}