@Test public void testFocusLevelTwoQuery() { String manufacturer = "Alice"; String component = "Bob"; Query query = new Query(); assertNotNull(query); assertNull(query.getManufacturer()); assertNull(query.getComponent()); query.setManufacturer(manufacturer); query.setComponent(component); assertEquals(query.getManufacturer(), manufacturer); assertEquals(query.getComponent(), component); assertEquals(query.getType(), QueryType.FOCUS_LEVEL_TWO); }
@Test public void testFocusLevelZeroQuery() { Query query = new Query(); assertNotNull(query); assertNull(query.getManufacturer()); assertNull(query.getComponent()); assertEquals(query.getType(), QueryType.FOCUS_LEVEL_ZERO); }
@Test public void testFocusLevelOneQuery() { String manufacturer = "Alice"; String component = "Bob"; Query manufacturerQuery = new Query(); assertNotNull(manufacturerQuery); assertNull(manufacturerQuery.getManufacturer()); assertNull(manufacturerQuery.getComponent()); manufacturerQuery.setManufacturer(manufacturer); assertEquals(manufacturerQuery.getManufacturer(), manufacturer); assertNull(manufacturerQuery.getComponent()); Query componentQuery = new Query(); assertNotNull(componentQuery); assertNull(componentQuery.getManufacturer()); assertNull(componentQuery.getComponent()); componentQuery.setComponent(component); assertEquals(componentQuery.getComponent(), component); assertNull(componentQuery.getManufacturer()); assertEquals(componentQuery.getType(), QueryType.FOCUS_LEVEL_ONE); assertEquals(manufacturerQuery.getType(), QueryType.FOCUS_LEVEL_ONE); }
@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; }