void ml::TakeLabelCensus(const RowList & Examples, map<int, size_t> & LabelCensus, size_t LabelAttributes, int LCValue) { ml::GenericTakeLabelCensus<RowList::const_iterator, int> (Examples.begin(), Examples.end(), LabelCensus, LabelAttributes, LCValue); }
void ml::TakeFeatureCensus(const RowList & Examples, map<size_t, map<double, size_t> > & FeatureCensus, const std::vector< std::pair<size_t, double> > & FeatureAttributes) { typedef typename std::map<double,size_t>::iterator CensusIterator; FeatureCensus.clear(); // set non-nominal census to expected, the count to 0, and // otherwise zero-out the nominal census. for (int i = 0; i < FeatureAttributes.size(); i++) { if (FeatureAttributes[i].first != 0) { for (int j = 0; j < FeatureAttributes[i].first; j++) { FeatureCensus[i][(double)j] = 0u; } } } for (RowListCIterator Row = Examples.begin(); Row != Examples.end(); Row++) { for (int i = 0; i < FeatureAttributes.size(); i++) { if (FeatureAttributes[i].first == 0) { continue; } if (Row->first->at(i) == UNKNOWN_VALUE) { FeatureCensus[i][FeatureAttributes[i].second]++; } else { FeatureCensus[i][Row->first->at(i)]++; } } } }