Returns a counter mapping from each class name to the probability of
that class for a certain example.
Looking at the the sum of each count v, should be 1.0.
977012
private Counter<L> probabilityOfRVFDatum(RVFDatum<L, F> example) {
    // NB: this duplicate method is needed so it calls the scoresOf method
    // with a RVFDatum signature
    Counter<L> scores = logProbabilityOfRVFDatum(example);
    for (L label : scores.keySet()) {
      scores.setCount(label, Math.exp(scores.getCount(label)));
    }
    return scores;
  }
157447
@Override
    public double[] getVotesForInstance(Instance instance) {
        if (this.reset == true) {
            return new double[2];
        }
        double[] probOfClassGivenDoc = new double[m_numClasses];
        double totalSize = totalSize(instance);

        for (int i = 0; i < m_numClasses; i++) {
            probOfClassGivenDoc[i] = Math.log(m_probOfClass[i]) - totalSize * Math.log(m_classTotals[i]);
        }

        for (int i = 0; i < instance.numValues(); i++) {

            int index = instance.index(i);
            if (index == instance.classIndex() || instance.isMissing(i)) {
                continue;
            }

            double wordCount = instance.valueSparse(i);
            for (int c = 0; c < m_numClasses; c++) {
                double value = m_wordTotalForClass[c].getValue(index);
                probOfClassGivenDoc[c] += wordCount * Math.log(value == 0 ? this.laplaceCorrectionOption.getValue() : value );
            }
        }

        return Utils.logs2probs(probOfClassGivenDoc);
    }
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;
  }
1257723
def counts_map(self):
        
        try:
            if isinstance(self.like, gtutils.SummedLikelihood):
                cmap = self.like.components[0].logLike.countsMap()
                p_method = cmap.projection().method()
            else:
                cmap = self.like.logLike.countsMap()
                p_method = cmap.projection().method()
        except Exception:
            p_method = 0

        if p_method == 0:  # WCS
            z = cmap.data()
            z = np.array(z).reshape(self.enumbins, self.npix, self.npix)
            return WcsNDMap(copy.deepcopy(self.geom), z)
        elif p_method == 1:  # HPX
            z = cmap.data()
            z = np.array(z).reshape(self.enumbins, np.max(self.geom.npix))
            return HpxNDMap(copy.deepcopy(self.geom), z)
        else:
            self.logger.error('Did not recognize CountsMap type %i' % p_method,
                              exc_info=True)
        return None
1323001
public static AssociativeArray sum(DataTable2D classifierClassProbabilityMatrix) {
        AssociativeArray combinedClassProbabilities = new AssociativeArray(); 
        
        for(Map.Entry<Object, AssociativeArray> entry : classifierClassProbabilityMatrix.entrySet()) {
            //Object classifier = entry.getKey();
            AssociativeArray listOfClassProbabilities = entry.getValue();
            for(Map.Entry<Object, Object> entry2 : listOfClassProbabilities.entrySet()) {
                Object theClass = entry2.getKey();
                Double probability = TypeInference.toDouble(entry2.getValue());
                
                Double previousValue = combinedClassProbabilities.getDouble(theClass);
                if(previousValue==null) { 
                    previousValue=0.0;
                }
                
                combinedClassProbabilities.put(theClass, previousValue+probability);
            }
        }
        
        return combinedClassProbabilities;
    }
849770
def counters!
      the_counters = { processing: 0 }

      names = @lifecycle.states.keys
      results = RedisRds::Object.connection.multi do
        self.class::STATES_TERMINAL.each { |name| get_list(name).size }
        names.each { |name| get_list(name).size }
        @processing.getall
      end

      (self.class::STATES_TERMINAL + names).each do |name|
        the_counters[name] = results.shift.to_i
      end

      the_counters[:processing] = results.shift.reduce(0) { |sum, pair| sum + pair.last.to_i }

      return the_counters
    end
213153
public Counter<K1> sumInnerCounter() {
    Counter<K1> summed = new ClassicCounter<K1>();
    for (K1 key : this.firstKeySet()) {
      summed.incrementCount(key, this.getCounter(key).totalCount());
    }
    return summed;
  }
1177278
public int getNrOfClasses() {
		HashMap<Integer, Integer> classes = new HashMap<Integer, Integer>();

		for (DataObject currentObject : dataList) {
			if (!classes.containsKey(currentObject.getClassLabel()))
				classes.put(currentObject.getClassLabel(), 1);
		}
    	
		return classes.size();
    }
959656
def get_counter(self, name=None):
        '''
        '''
        return self.get_client(name=name, class_=statsd.Counter)
1236783
def calculate_perf_counter_bulk_count(previous, current, property_name):
    
    n0 = previous[property_name]
    n1 = current[property_name]
    d0 = previous["Timestamp_Sys100NS"]
    d1 = current["Timestamp_Sys100NS"]
    f = current["Frequency_Sys100NS"]

    if n0 is None or n1 is None:
        return

    return (n1 - n0) / ((d1 - d0) / f)
82802
def _process_counter_example(self, mma, w_string):
        "
        if len(w_string) == 1:
            self.observation_table.smi_vector.append(w_string)
            for exp in self.observation_table.em_vector:
                self._fill_table_entry(w_string, exp)

        diff = len(w_string)
        same = 0
        membership_answer = self._membership_query(w_string)
        while True:
            i = (same + diff) / 2
            access_string = self._run_in_hypothesis(mma, w_string, i)
            if membership_answer != self._membership_query(access_string + w_string[i:]):
                diff = i
            else:
                same = i
            if diff - same == 1:
                break

        # First check if the transition is part of our training data.
        access_string = self._run_in_hypothesis(mma, w_string, diff - 1)
        wrong_transition = access_string + w_string[diff - 1]
        if wrong_transition not in self.observation_table.smi_vector:
            # If transition is not part of our training data add s_ib to Smi and
            # return to checking table closedness.
            self.observation_table.smi_vector.append(wrong_transition)
            for exp in self.observation_table.em_vector:
                self._fill_table_entry(wrong_transition, exp)
            return

        # This point presents a tradeoff between equivalence and membership
        # queries. If the transition in the counterexample'input_string breakpoint is not
        # part of our current training data (i.e. s_ib is not part of our Smi
        # set), then we assume a wrong transition and return to checking table
        # closure by adding s_ib to our training data. This saves a number of
        # membership queries since we don't add a row in our table unless
        # absolutely necessary. Notice that even if Equivalence queries are
        # expensive in general caching the result will be able to discover that
        # this iteration required a new state in the next equivalence query.

        exp = w_string[diff:]
        self.observation_table.em_vector.append(exp)
        for row in self.observation_table.sm_vector + self.observation_table.smi_vector:
            self._fill_table_entry(row, exp)
184686
public double getCount(A first, B second) {
    if (counts.containsKey(first) && counts.get(first).containsKey(second)) {
      return counts.get(first).get(second);
    }
    return 0.0;
  }
708307
def count_by_value_impl(sequence):
    
    counter = collections.Counter()
    for e in sequence:
        counter[e] += 1
    return six.viewitems(counter)
579382
public long countClass(final String iClassName) {
    final OClass cls = getMetadata().getSchema().getClass(iClassName);

    if (cls == null)
      throw new IllegalArgumentException("Class '" + iClassName + "' not found in database");

    return cls.count();
  }
1245679
private int getIndexOfClass(List list, Class cls) {
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getClass().equals(cls)) {
                return i;
            }
        }
        return -1;
    }
1176215
@Override
	public double getInclusionProbability(Instance instance) {
		Iterator<Map.Entry<DensityGrid, Boolean>> gridIter = grids.entrySet().iterator();
		
		while(gridIter.hasNext())
		{
			Map.Entry<DensityGrid, Boolean> grid = gridIter.next();
			DensityGrid dg = grid.getKey();
			if(dg.getInclusionProbability(instance) == 1.0)
				return 1.0;
		}
		
		return 0.0;
	}
740739
def calculate_probabilities(tokens)
      # P(class|words) = P(w1,...,wn|class) * P(class) / P(w1,...,wn)
      #                = argmax P(w1,...,wn|class) * P(class)
      #
      # P(wi|class) = (count(wi, class) + k)/(count(w,class) + kV)
      prob_numerator = {}
      v_size = vocab.size

      cat_prob = Math.log(1 / data.categories.count.to_f)
      total_example_count = data.total_examples.to_f

      data.each do |category|
        unless assume_uniform
          cat_prob = Math.log(data.example_count(category) / total_example_count)
        end

        log_probs = 0
        denominator = (data.token_count(category) + @k * v_size).to_f
        tokens.each do |token|
          numerator = data.count_of_token_in_category(category, token) + @k
          log_probs += Math.log( numerator / denominator )
        end
        prob_numerator[category] = log_probs + cat_prob
      end
      normalize(prob_numerator)
    end