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