Ejemplo n.º 1
0
 def _set_weight(self, feature, weight):
     logger.debug("Setting feature: %s frow weight: %s to weight: %s",
                  util.pp(feature), util.pp(self._get_weight(feature)),
                  util.pp(weight))
     assert not np.isnan(weight.mean)
     assert weight.variance >= 0.0
     self._weights[util.serialize_feature(feature)] = weight
Ejemplo n.º 2
0
 def _set_weight(self, feature, weight):
     logger.debug("Setting feature: %s frow weight: %s to weight: %s",
                  util.pp(feature),
                  util.pp(self._get_weight(feature)),
                  util.pp(weight))
     assert not np.isnan(weight.mean)
     assert weight.variance >= 0.0
     self._weights[util.serialize_feature(feature)] = weight
Ejemplo n.º 3
0
 def _construct_biased_weights(simulation):
     biased_weights = {}
     for feature, value in itertools.product(
             range(1, simulation.predictor_config.num_features),
             range(simulation.feature_cardinality)):
         key = util.serialize_feature(
             pb.Feature(feature=feature, value=value))
         if np.random.rand() < simulation.biased_feature_proportion:
             direction = np.random.rand() < \
                 simulation.predictor_config.prior_probability
             biased_weights[key] = direction
             logger.info("Biased truth feature (%s, %s) to %s", feature,
                         value, direction)
     return biased_weights
Ejemplo n.º 4
0
 def _construct_biased_weights(simulation):
     biased_weights = {}
     for feature, value in itertools.product(
             range(1, simulation.predictor_config.num_features),
             range(simulation.feature_cardinality)):
         key = util.serialize_feature(
             pb.Feature(feature=feature, value=value))
         if np.random.rand() < simulation.biased_feature_proportion:
             direction = np.random.rand() < \
                 simulation.predictor_config.prior_probability
             biased_weights[key] = direction
             logger.info("Biased truth feature (%s, %s) to %s",
                         feature, value, direction)
     return biased_weights
Ejemplo n.º 5
0
 def get_bias_for_feature(self, feature):
     return self._biased_weights.get(util.serialize_feature(feature))
Ejemplo n.º 6
0
 def get_bias_for_feature(self, feature):
     return self._biased_weights.get(util.serialize_feature(feature))
Ejemplo n.º 7
0
 def _get_weight(self, feature):
     return self._weights.get(util.serialize_feature(feature),
                              util.prior_weight())
Ejemplo n.º 8
0
 def _get_weight(self, feature):
     return self._weights.get(
         util.serialize_feature(feature),
         util.prior_weight())