Ejemplo n.º 1
0
 @Override
 public double getPrediction(Query q) {
   /*
    * Return baseline probs including the IS effect
    */
   double ISeffect;
   if (q.getType() == QueryType.FOCUS_LEVEL_ZERO) {
     double F0Users = 0.0;
     double ISUsers = 0.0;
     for (Query q2 : _querySpace) {
       if (q2.getManufacturer() != null && q2.getComponent() != null) {
         Product prod = new Product(q2.getManufacturer(), q2.getComponent());
         F0Users += _userModel.getPrediction(prod, GameStatusHandler.UserState.F0);
         ISUsers += _userModel.getPrediction(prod, GameStatusHandler.UserState.IS);
       }
     }
     ISeffect = F0Users / ((1 / 3.0) * ISUsers + F0Users);
   } else if (q.getType() == QueryType.FOCUS_LEVEL_ONE) {
     double F1Users = 0.0;
     double ISUsers = 0.0;
     for (Query q2 : _querySpace) {
       if ((q.getManufacturer() != null
               && q.getManufacturer().equals(q2.getManufacturer())
               && q2.getComponent() != null)
           || (q.getComponent() != null
               && q.getComponent().equals(q2.getComponent())
               && q2.getManufacturer() != null)) {
         Product prod = new Product(q2.getManufacturer(), q2.getComponent());
         F1Users += .5 * _userModel.getPrediction(prod, GameStatusHandler.UserState.F1);
         ISUsers += .5 * _userModel.getPrediction(prod, GameStatusHandler.UserState.IS);
       }
     }
     ISeffect = F1Users / ((1 / 3.0) * ISUsers + F1Users);
   } else if (q.getType() == QueryType.FOCUS_LEVEL_TWO) {
     Product prod = new Product(q.getManufacturer(), q.getComponent());
     double F2Users = _userModel.getPrediction(prod, GameStatusHandler.UserState.F2);
     double ISUsers = _userModel.getPrediction(prod, GameStatusHandler.UserState.IS);
     ISeffect = F2Users / ((1 / 3.0) * ISUsers + F2Users);
   } else {
     throw new RuntimeException("Malformed query");
   }
   double convPr = _baselineConvPr.get(q) * ISeffect;
   return convPr;
 }