protected function prepareFprime(array &$feature_array, array &$l)
    {
        $this->denominators = array();
        foreach ($feature_array as $offset=>$doc) {
            $numerator = array_fill_keys(array_keys($doc),0.0);
            $denominator = 0.0;
            foreach ($doc as $cl=>$f) {
                if (!is_array($f)) continue;
                $tmp = 0.0;
                foreach ($f as $i) {
                    $tmp += $l[$i];
                }
                $tmp = exp($tmp);
                $numerator[$cl] += $tmp;
                $denominator += $tmp;
            }
            foreach ($doc as $class=>$features) {
                if (!is_array($features)) continue;
                foreach ($features as $fi) {
                    if (!isset($this->denominators[$fi])) {
                        $this->denominators[$fi] = 0;
                    }
                    $this->denominators[$fi] += $numerator[$class]/$denominator;
                }
            }
        }
    }
protected function prepareFprime(array &$feature_array, array &$l)
    {
        $this->denominators = array();
        foreach ($feature_array as $offset=>$doc) {
            $numerator = array_fill_keys(array_keys($doc),0.0);
            $denominator = 0.0;
            foreach ($doc as $cl=>$f) {
                if (!is_array($f)) continue;
                $tmp = 0.0;
                foreach ($f as $i) {
                    $tmp += $l[$i];
                }
                $tmp = exp($tmp);
                $numerator[$cl] += $tmp;
                $denominator += $tmp;
            }
            foreach ($doc as $class=>$features) {
                if (!is_array($features)) continue;
                foreach ($features as $fi) {
                    if (!isset($this->denominators[$fi])) {
                        $this->denominators[$fi] = 0;
                    }
                    $this->denominators[$fi] += $numerator[$class]/$denominator;
                }
            }
        }
    }
protected function prepareFprime ( array & $ feature_array , array & $ l ) { $ this -> denominators = array ( ) ; foreach ( $ feature_array as $ offset => $ doc ) { $ numerator = array_fill_keys ( array_keys ( $ doc ) , 0.0 ) ; $ denominator = 0.0 ; foreach ( $ doc as $ cl => $ f ) { if ( ! is_array ( $ f ) ) continue ; $ tmp = 0.0 ; foreach ( $ f as $ i ) { $ tmp += $ l [ $ i ] ; } $ tmp = exp ( $ tmp ) ; $ numerator [ $ cl ] += $ tmp ; $ denominator += $ tmp ; } foreach ( $ doc as $ class => $ features ) { if ( ! is_array ( $ features ) ) continue ; foreach ( $ features as $ fi ) { if ( ! isset ( $ this -> denominators [ $ fi ] ) ) { $ this -> denominators [ $ fi ] = 0 ; } $ this -> denominators [ $ fi ] += $ numerator [ $ class ] / $ denominator ; } } } }
Compute the denominators which is the predicted expectation of
each feature given a set of weights L and a set of features for
each document for each class.

@param $feature_array All the data known about the training set
@param $l The current set of weights to be initialized
@return void
Compute the denominators which is the predicted expectation of each feature given a set of weights L and a set of features for each document for each class .