protected function calculateFeatureArray(array $classes, TrainingSet $tset, FeatureFactoryInterface $ff)
    {
        $features = array();
        $tset->setAsKey(TrainingSet::OFFSET_AS_KEY);
        foreach ($tset as $offset=>$doc) {
            $features[$offset] = array();
            foreach ($classes as $class) {
                $features[$offset][$class] = $ff->getFeatureArray($class,$doc);
            }
            $features[$offset]['__label__'] = $doc->getClass();
        }

        return $features;
    }
protected function calculateFeatureArray(array $classes, TrainingSet $tset, FeatureFactoryInterface $ff)
    {
        $features = array();
        $tset->setAsKey(TrainingSet::OFFSET_AS_KEY);
        foreach ($tset as $offset=>$doc) {
            $features[$offset] = array();
            foreach ($classes as $class) {
                $features[$offset][$class] = $ff->getFeatureArray($class,$doc);
            }
            $features[$offset]['__label__'] = $doc->getClass();
        }

        return $features;
    }
protected function calculateFeatureArray ( array $ classes , TrainingSet $ tset , FeatureFactoryInterface $ ff ) { $ features = array ( ) ; $ tset -> setAsKey ( TrainingSet :: OFFSET_AS_KEY ) ; foreach ( $ tset as $ offset => $ doc ) { $ features [ $ offset ] = array ( ) ; foreach ( $ classes as $ class ) { $ features [ $ offset ] [ $ class ] = $ ff -> getFeatureArray ( $ class , $ doc ) ; } $ features [ $ offset ] [ '__label__' ] = $ doc -> getClass ( ) ; } return $ features ; }
Calculate all the features for each possible class of each
document. This is done so that we can optimize without the need
of the FeatureFactory.

We do not want to use the FeatureFactoryInterface both because it would
be slow to calculate the features over and over again, but also
because we want to be able to optimize externally to
gain speed (PHP is slow!).

@param $classes A set of the classes in the training set
@param $tset A collection of training documents
@param $ff The feature factory
@return array An array that contains every feature for every possible class of every document
Calculate all the features for each possible class of each document . This is done so that we can optimize without the need of the FeatureFactory .