Skip to content

Commit

Permalink
updated LogLoss (boosting) for numerical stability
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbradley committed Nov 26, 2014
1 parent 5e52bff commit ed5da2c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ object LogLoss extends Loss {
override def computeError(model: TreeEnsembleModel, data: RDD[LabeledPoint]): Double = {
data.map { case point =>
val prediction = model.predict(point.features)
2.0 * math.log(1 + math.exp(-2.0 * point.label * prediction))
// Use log1p since it is more stable than explicitly writing log(1 + exp()).
2.0 * math.log1p(math.exp(-2.0 * point.label * prediction))
}.mean()
}
}

0 comments on commit ed5da2c

Please sign in to comment.