MLClassListPtr FeatureVectorList::ExtractListOfClasses () const { MLClassPtr lastClass = NULL; map<MLClassPtr,MLClassPtr> ptrIndex; map<MLClassPtr,MLClassPtr>::iterator ptrIndexItr; FeatureVectorList::const_iterator idx; for (idx = begin (); idx != end (); ++idx) { FeatureVectorPtr example = *idx; MLClassPtr newClass = example->MLClass (); if (newClass == lastClass) continue; lastClass = newClass; ptrIndexItr = ptrIndex.find (newClass); if (ptrIndexItr == ptrIndex.end ()) { lastClass = newClass; ptrIndex.insert (pair<MLClassPtr,MLClassPtr> (newClass, newClass)); } } MLClassListPtr classes = new MLClassList (); for (ptrIndexItr = ptrIndex.begin (); ptrIndexItr != ptrIndex.end (); ++ptrIndexItr) classes->PushOnBack (ptrIndexItr->first); return classes; } /* ExtractListOfClasses */
MLClassListPtr Classifier2::PredictionsThatHaveSubClassifier (ClassProbListPtr predictions) { MLClassListPtr classes = new MLClassList (); ClassProbList::iterator idx; for (idx = predictions->begin (); idx != predictions->end (); ++idx) { ClassProbPtr cp = *idx; Classifier2Ptr subClassifier = LookUpSubClassifietByClass (cp->classLabel); if (subClassifier) classes->PushOnBack (cp->classLabel); } return classes; } /* PredictionsThatHaveSubClassifier */