MCPcopy Create free account
hub / github.com/creatale/node-dv / FindNZFeatureMapping

Method FindNZFeatureMapping

deps/tesseract/classify/intfeaturemap.cpp:133–154  ·  view source on GitHub ↗

Computes the features used by the subset of samples defined by the iterator and sets up the feature mapping. Returns the size of the compacted feature space.

Source from the content-addressed store, hash-verified

131// the iterator and sets up the feature mapping.
132// Returns the size of the compacted feature space.
133int IntFeatureMap::FindNZFeatureMapping(SampleIterator* it) {
134 feature_map_.Init(feature_space_.Size(), false);
135 int total_samples = 0;
136 for (it->Begin(); !it->AtEnd(); it->Next()) {
137 const TrainingSample& sample = it->GetSample();
138 GenericVector<int> features;
139 feature_space_.IndexAndSortFeatures(sample.features(),
140 sample.num_features(),
141 &features);
142 int num_features = features.size();
143 for (int f = 0; f < num_features; ++f)
144 feature_map_.SetMap(features[f], true);
145 ++total_samples;
146 }
147 feature_map_.Setup();
148 compact_size_ = feature_map_.CompactSize();
149 mapping_changed_ = true;
150 FinalizeMapping(it);
151 tprintf("%d non-zero features found in %d samples\n",
152 compact_size_, total_samples);
153 return compact_size_;
154}
155#endif
156
157// After deleting some features, finish setting up the mapping, and map

Callers

nothing calls this directly

Calls 13

SizeMethod · 0.80
AtEndMethod · 0.80
GetSampleMethod · 0.80
featuresMethod · 0.80
num_featuresMethod · 0.80
SetMapMethod · 0.80
SetupMethod · 0.80
CompactSizeMethod · 0.80
InitMethod · 0.45
BeginMethod · 0.45
NextMethod · 0.45
IndexAndSortFeaturesMethod · 0.45

Tested by

no test coverage detected