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

com.expleague.ml.methods.greedyRegion.AdditiveStatisticsExtractors Maven / Gradle / Ivy

There is a newer version: 1.4.9
Show newest version
package com.expleague.ml.methods.greedyRegion;

import com.expleague.ml.loss.WeightedLoss;
import com.expleague.commons.func.AdditiveStatistics;
import com.expleague.ml.loss.L2;

/**
 * Created by noxoomo on 10/11/14.
 */
public class AdditiveStatisticsExtractors {
  public static double weight(final AdditiveStatistics stats) {
    if (stats instanceof WeightedLoss.Stat) {
      return ((L2.Stat) ((WeightedLoss.Stat) stats).inside).weight;
    }
    if (stats instanceof L2.Stat) {
      return ((L2.Stat) stats).weight;
    }
    return 0;
  }

  public static double sum(final AdditiveStatistics stats) {
    if (stats instanceof WeightedLoss.Stat) {
      return ((L2.Stat) ((WeightedLoss.Stat) stats).inside).sum;
    }
    if (stats instanceof L2.Stat) {
      return ((L2.Stat) stats).sum;
    }
    return 0;
  }

  public static double sum2(final AdditiveStatistics stats) {
    if (stats instanceof WeightedLoss.Stat) {
      return ((L2.Stat) ((WeightedLoss.Stat) stats).inside).sum2;
    }
    if (stats instanceof L2.Stat) {
      return ((L2.Stat) stats).sum2;
    }
    return 0;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy