protected function computeProbabilitiesFromCounts(array $class_set, array &$termcount_per_class, array &$termcount, array &$ndocs_per_class, $ndocs, $voccount, $a_smoothing=1)
    {
        $denom_smoothing = $a_smoothing*$voccount;
        foreach ($class_set as $class) {
            $this->priors[$class] = $ndocs_per_class[$class] / $ndocs;
            foreach ($termcount[$class] as $term=>$count) {
                $this->condprob[$term][$class] = ($count + $a_smoothing) / ($termcount_per_class[$class] + $denom_smoothing);
            }
        }
        foreach ($class_set as $class) {
            $this->unknown[$class] = $a_smoothing / ($termcount_per_class[$class] + $denom_smoothing);
        }
    }
protected function computeProbabilitiesFromCounts(array $class_set, array &$termcount_per_class, array &$termcount, array &$ndocs_per_class, $ndocs, $voccount, $a_smoothing=1)
    {
        $denom_smoothing = $a_smoothing*$voccount;
        foreach ($class_set as $class) {
            $this->priors[$class] = $ndocs_per_class[$class] / $ndocs;
            foreach ($termcount[$class] as $term=>$count) {
                $this->condprob[$term][$class] = ($count + $a_smoothing) / ($termcount_per_class[$class] + $denom_smoothing);
            }
        }
        foreach ($class_set as $class) {
            $this->unknown[$class] = $a_smoothing / ($termcount_per_class[$class] + $denom_smoothing);
        }
    }
protected function computeProbabilitiesFromCounts ( array $ class_set , array & $ termcount_per_class , array & $ termcount , array & $ ndocs_per_class , $ ndocs , $ voccount , $ a_smoothing = 1 ) { $ denom_smoothing = $ a_smoothing * $ voccount ; foreach ( $ class_set as $ class ) { $ this -> priors [ $ class ] = $ ndocs_per_class [ $ class ] / $ ndocs ; foreach ( $ termcount [ $ class ] as $ term => $ count ) { $ this -> condprob [ $ term ] [ $ class ] = ( $ count + $ a_smoothing ) / ( $ termcount_per_class [ $ class ] + $ denom_smoothing ) ; } } foreach ( $ class_set as $ class ) { $ this -> unknown [ $ class ] = $ a_smoothing / ( $ termcount_per_class [ $ class ] + $ denom_smoothing ) ; } }
Compute the probabilities given the counts of the features in the
training set.

@param  array   $class_set           Just the array that contains the classes
@param  array   $termcount_per_class The count of occurences of each feature in each class
@param  array   $termcount           The total count of occurences of each term
@param  array   $ndocs_per_class     The total number of documents per class
@param  integer $ndocs               The total number of documents
@param  integer $voccount            The total number of features found
@return void
Compute the probabilities given the counts of the features in the training set .