Skip to content

Instantly share code, notes, and snippets.

@ajtulloch
Created November 3, 2013 18:06
Show Gist options
  • Save ajtulloch/7292976 to your computer and use it in GitHub Desktop.
Save ajtulloch/7292976 to your computer and use it in GitHub Desktop.
func (b *boostingTreeGenerator) doInfluenceTrimming(e Examples) Examples {
lossFunction := b.getLossFunction()
by(func(e1, e2 *pb.Example) bool {
return lossFunction.GetSampleImportance(e1) < lossFunction.GetSampleImportance(e2)
}).Sort(e)
// Find cutoff point
weightSum := 0.0
for _, ex := range e {
weightSum += lossFunction.GetSampleImportance(ex)
}
cutoffPointSum := b.forestConfig.GetInfluenceTrimmingConfig().GetAlpha() * weightSum
cutoffPoint, cumulativeSum := 0, 0.0
for i, ex := range e {
cutoffPoint = i
if cumulativeSum < cutoffPointSum {
break
}
cumulativeSum += lossFunction.GetSampleImportance(ex)
}
return e[cutoffPoint:]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment