Skip to content

Commit

Permalink
add Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fjiang6 committed Aug 6, 2015
1 parent 4f0865f commit a79855a
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ import org.apache.spark.sql.functions.{col, udf}
import org.apache.spark.storage.StorageLevel
import org.apache.spark.util.StatCounter

import scala.math.pow

/**
* Params for linear regression.
*/
Expand Down Expand Up @@ -810,11 +808,11 @@ private class HuberCostFun(
val norm = brzNorm(weights, 2.0)
var regVal = 0.0
if(diff < -k){
regVal = -k * 0.5 * effectiveL2regParam * diff - 0.5 * pow(k, 2)
regVal = -k * 0.5 * effectiveL2regParam * diff - 0.5 * k * k
} else if (diff >= -k && diff <= k){
regVal = 0.25 * effectiveL2regParam * norm * norm
} else {
regVal = k * 0.5 * effectiveL2regParam * diff - 0.5 * pow(k, 2)
regVal = k * 0.5 * effectiveL2regParam * diff - 0.5 * k * k
}

val loss = leastSquaresAggregator.loss + regVal
Expand Down

0 comments on commit a79855a

Please sign in to comment.