func (l *lossState) removeExample(e *pb.Example) {
	l.numExamples -= 1
	delta := e.GetWeightedLabel() - l.averageLabel
	l.averageLabel -= delta / float64(l.numExamples)
	newDelta := e.GetWeightedLabel() - l.averageLabel
	l.sumSquaredDivergence -= delta * newDelta
}
Esempio n. 2
0
func (l leastAbsoluteDeviationLoss) residual(ex *pb.Example) float64 {
	return ex.GetLabel() - l.evaluator.Evaluate(ex.Features)
}
Esempio n. 3
0
func (l logitLoss) GetSampleImportance(ex *pb.Example) float64 {
	prediction := l.evaluator.Evaluate(ex.Features)
	weightedLabel := 2 * ex.GetLabel() / (1 + math.Exp(2*ex.GetLabel()*prediction))
	return math.Abs(weightedLabel) * (2 - math.Abs(weightedLabel))
}
Esempio n. 4
0
func (h huberLoss) residual(ex *pb.Example) float64 {
	return ex.GetLabel() - h.evaluator.Evaluate(ex.Features)
}