MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / BootstrapGini

Function BootstrapGini

tensorflow/contrib/tensor_forest/kernels/tree_utils.cc:217–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217int BootstrapGini(int n, int s, const random::DistributionSampler& ds,
218 random::SimplePhilox* rand) {
219 std::vector<int> counts(s, 0);
220 for (int i = 0; i < n; i++) {
221 int j = ds.Sample(rand);
222 counts[j] += 1;
223 }
224 int g = 0;
225 for (int j = 0; j < s; j++) {
226 g += counts[j] * counts[j];
227 }
228 // The true gini is 1 + (-g) / n^2
229 return -g;
230}
231
232// Populate *weights with the smoothed per-class frequencies needed to
233// initialize a DistributionSampler. Returns the total number of samples

Calls 1

SampleMethod · 0.45

Tested by

no test coverage detected