Given a datum's features, construct a counter with keys
the labels and values the score (unnormalized log probability)
for each class.
6702
public Counter<L> scoresOf(int[] features) {
    Counter<L> scores = new ClassicCounter<L>();
    for (L label : labels())
      scores.setCount(label, scoreOf(features, label));
    return scores;
  }
72532
def score_file(filename):
  """"""
  # Prepare model.
  hparams = create_hparams()
  encoders = registry.problem(FLAGS.problem).feature_encoders(FLAGS.data_dir)
  has_inputs = "inputs" in encoders

  # Prepare features for feeding into the model.
  if has_inputs:
    inputs_ph = tf.placeholder(dtype=tf.int32)  # Just length dimension.
    batch_inputs = tf.reshape(inputs_ph, [1, -1, 1, 1])  # Make it 4D.
  targets_ph = tf.placeholder(dtype=tf.int32)  # Just length dimension.
  batch_targets = tf.reshape(targets_ph, [1, -1, 1, 1])  # Make it 4D.
  if has_inputs:
    features = {"inputs": batch_inputs, "targets": batch_targets}
  else:
    features = {"targets": batch_targets}

  # Prepare the model and the graph when model runs on features.
  model = registry.model(FLAGS.model)(hparams, tf.estimator.ModeKeys.EVAL)
  _, losses = model(features)
  saver = tf.train.Saver()

  with tf.Session() as sess:
    # Load weights from checkpoint.
    if FLAGS.checkpoint_path is None:
      ckpts = tf.train.get_checkpoint_state(FLAGS.output_dir)
      ckpt = ckpts.model_checkpoint_path
    else:
      ckpt = FLAGS.checkpoint_path
    saver.restore(sess, ckpt)
    # Run on each line.
    with tf.gfile.Open(filename) as f:
      lines = f.readlines()
    results = []
    for line in lines:
      tab_split = line.split("\t")
      if len(tab_split) > 2:
        raise ValueError("Each line must have at most one tab separator.")
      if len(tab_split) == 1:
        targets = tab_split[0].strip()
      else:
        targets = tab_split[1].strip()
        inputs = tab_split[0].strip()
      # Run encoders and append EOS symbol.
      targets_numpy = encoders["targets"].encode(
          targets) + [text_encoder.EOS_ID]
      if has_inputs:
        inputs_numpy = encoders["inputs"].encode(inputs) + [text_encoder.EOS_ID]
      # Prepare the feed.
      if has_inputs:
        feed = {inputs_ph: inputs_numpy, targets_ph: targets_numpy}
      else:
        feed = {targets_ph: targets_numpy}
      # Get the score.
      np_loss = sess.run(losses["training"], feed)
      results.append(np_loss)
  return results
285640
public double scoreOf(Datum<L, F> example, L label) {
    if(example instanceof RVFDatum<?, ?>)return scoreOfRVFDatum((RVFDatum<L,F>)example, label);
    int iLabel = labelIndex.indexOf(label);
    double score = 0.0;
    for (F f : example.asFeatures()) {
      score += weight(f, iLabel);
    }
    return score + thresholds[iLabel];
  }
848134
def count_features_type(features):
        
    counter={k.name: v for k, v in features.columns.to_series().groupby(features.dtypes)}
    binary=0
    if ('int64' in counter):
        binary=len(set(features.loc[:, (features<=1).all(axis=0)].columns.values) 
                & set(features.loc[:, (features>=0).all(axis=0)].columns.values) 
                & set(counter['int64']))    
    return (binary,len(counter['int64'])-binary if 'int64' in counter else 0,len(counter['float64']) if 'float64' in counter else 0)
1178730
public double score(List<L> guesses, List<L> trueLabels, Index<L> dataLabelIndex) {
    setLabelIndex(dataLabelIndex);
    return score(guesses, trueLabels);
  }
142683
public Counter<L> probabilityOf(Datum<L, F> example) {
    if(example instanceof RVFDatum<?, ?>)return probabilityOfRVFDatum((RVFDatum<L,F>)example);
    Counter<L> scores = logProbabilityOf(example);
    for (L label : scores.keySet()) {
      scores.setCount(label, Math.exp(scores.getCount(label)));
    }
    return scores;
  }
948341
def compute_rarity_scores_log(exemplars):
    
    scores = defaultdict(lambda: 0.)
    for followers in exemplars.values():
        score = 1. / math.log(len(followers))
        for f in followers:
            scores[f] += score
    return scores
9483
def SURFstar_compute_scores(inst, attr, nan_entries, num_attributes, mcmap, NN_near, NN_far, headers, class_type, X, y, labels_std, data_type):
    
    scores = np.zeros(num_attributes)
    for feature_num in range(num_attributes):
        if len(NN_near) > 0:
            scores[feature_num] += compute_score(attr, mcmap, NN_near, feature_num, inst,
                                                 nan_entries, headers, class_type, X, y, labels_std, data_type)
        # Note that we are using the near scoring loop in 'compute_score' and then just subtracting it here, in line with original SURF* paper.
        if len(NN_far) > 0:
            scores[feature_num] -= compute_score(attr, mcmap, NN_far, feature_num, inst,
                                                 nan_entries, headers, class_type, X, y, labels_std, data_type)
    return scores
265807
def compute_rewards(self, scores):
        """"""
        if len(scores) > self.k:
            scores = np.copy(scores)
            inds = np.argsort(scores)[:-self.k]
            scores[inds] = np.nan

        return list(scores)
1239655
public Optional<FMeasureInfo> score(final Iterable<? extends Iterable<?>> predicted,
      final Iterable<? extends Iterable<?>> gold) {
    final List<Set<Object>> predictedAsSets = CorefScorerUtils.toSets(predicted);
    final List<Set<Object>> goldAsSets = CorefScorerUtils.toSets(gold);

    final Map<Object, Set<Object>> predictedItemToGroup =
        CollectionUtils.makeElementsToContainersMap(predictedAsSets);
    final Map<Object, Set<Object>> goldItemToGroup =
        CollectionUtils.makeElementsToContainersMap(goldAsSets);

    CorefScorerUtils.checkPartitionsOverSameElements(predictedItemToGroup.keySet(),
        goldItemToGroup.keySet());

    final Optional<Float> recall =
        mucScoreComponent(goldAsSets, predictedAsSets, predictedItemToGroup);
    final Optional<Float> precision =
        mucScoreComponent(predictedAsSets, goldAsSets, goldItemToGroup);

    if (recall.isPresent() && precision.isPresent()) {
      // why are these floats?
      return Optional.<FMeasureInfo>of(new PrecisionRecallPair(precision.get(), recall.get()));
    } else {
      return Optional.absent();
    }
  }
1285119
def _process_score(self, model_name, dependency_cache=None):
        
        version = self[model_name].version

        start = time.time()
        feature_values = self._solve_features(model_name, dependency_cache)
        logger.debug("Extracted features for {0}:{1}:{2} in {3} secs"
                     .format(self.name, model_name, version,
                             round(time.time() - start, 3)))

        start = time.time()
        score = self[model_name].score(feature_values)
        logger.debug("Scored features for {0}:{1}:{2} in {3} secs"
                     .format(self.name, model_name, version,
                             round(time.time() - start, 3)))

        return score
124655
def calculate_priority(ratios=None, **kwargs):
    ""
    if not ratios:
        ratios = PRIORITY_FEATURE_WEIGHTS
    scores = [DEFAULT_PRIORITY_SCORE]
    for key, value in kwargs.items():
        if key not in PRIORITY_FEATURE_WEIGHTS:
            raise KeyError('The following keyword arguments are supported: '
                           '{keys}'.format(keys=PRIORITY_FEATURES))
        if value is True:
            scores.append(PRIORITY_FEATURE_WEIGHTS[key])
    return float(sum(scores)) / len(scores)
1288928
def predict(self, X):
        
        logprob, responsibilities = self.score_samples(X)
        return responsibilities.argmax(axis=1)
817450
def _count_classified_pixels(self):
        
        class_values = self.class_dictionary.values()

        classification_count = np.array([[[np.count_nonzero(prediction[np.nonzero(mask)] == class_val)
                                           for prediction, mask in zip(self.classification_masks, masktype)]
                                          for masktype in self.truth_masks]
                                         for class_val in class_values])

        classification_count = np.moveaxis(classification_count, 0, -1)
        classification_count = np.moveaxis(classification_count, 0, -2)

        if self.pixel_classification_counts is None:
            self.pixel_classification_counts = np.copy(classification_count)
        else:
            self.pixel_classification_counts = np.concatenate((self.pixel_classification_counts, classification_count))
1200345
public Counter<L> logProbabilityOf(Datum<L, F> example) {
    if(example instanceof RVFDatum<?, ?>)return logProbabilityOfRVFDatum((RVFDatum<L,F>)example);
    Counter<L> scores = scoresOf(example);
    Counters.logNormalizeInPlace(scores);
    return scores;
  }
1292557
@Override protected double[] score0(double[] data, double[] preds, double offset, int ntrees) {
    super.score0(data, preds, offset, ntrees);
    int N = _output._ntrees;
    if (_output.nclasses() == 1) { // regression - compute avg over all trees
      if (N>=1) preds[0] /= N;
    } else { // classification
      if (_output.nclasses() == 2 && binomialOpt()) {
        if (N>=1) {
          preds[1] /= N; //average probability
        }
        preds[2] = 1. - preds[1];
      } else {
        double sum = MathUtils.sum(preds);
        if (sum > 0) MathUtils.div(preds, sum);
      }
    }
    return preds;
  }
1056182
def score_counts(counts)
      if counts.count > 0
        _num = counts.map { |x| x.obp }
        _num.percentile(90)
      else
        0.01
      end
    end