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;
    }