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.
| 131 | // the iterator and sets up the feature mapping. |
| 132 | // Returns the size of the compacted feature space. |
| 133 | int 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 |
nothing calls this directly
no test coverage detected