Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
func (l leastAbsoluteDeviationLoss) residual(ex *pb.Example) float64 {
	return ex.GetLabel() - l.evaluator.Evaluate(ex.Features)
}
Ejemplo 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))
}
Ejemplo n.º 4
0
func (h huberLoss) residual(ex *pb.Example) float64 {
	return ex.GetLabel() - h.evaluator.Evaluate(ex.Features)
}