@Override
 public double getLoss(
     List<? extends AbstractInstance> crossValSet, PredictiveModel predictiveModel) {
   Auc auc = new Auc();
   for (AbstractInstance instance : crossValSet) {
     auc.add(
         (Double) instance.getClassification() == 1.0 ? 1 : 0,
         predictiveModel.getProbability(instance.getAttributes(), 1.0));
   }
   return 1 - auc.auc();
 }
Exemple #2
0
  private static HashMap<String, ClicksAndImps> uniqueBrowserDataPredicted(
      PredictiveModel predictiveModel, List<Instance> instances) {
    HashMap<String, ClicksAndImps> uniqueBrowsers = new HashMap<>();
    for (Instance instance : instances) {
      String browser = (String) instance.getAttributes().get("an_browser");
      double clickProb =
          Utils.correctProbability(
              .99, predictiveModel.getProbability(instance.getAttributes(), 1.0));

      if (browser != null) {
        int count = 0;
        if (!uniqueBrowsers.containsKey(browser)) {
          uniqueBrowsers.put(browser, new ClicksAndImps());
        }
        uniqueBrowsers.get(browser).imps++;
        uniqueBrowsers.get(browser).clicks += clickProb;
      }
    }
    for (String key : uniqueBrowsers.keySet()) {
      uniqueBrowsers.get(key).setCtr();
    }
    return uniqueBrowsers;
  }