Skip to content

Commit c40eba3

Browse files
committed
update
1 parent 21e7ff7 commit c40eba3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mllib/src/main/scala/org/apache/spark/ml/optim/WeightedLeastSquares.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,12 @@ private[ml] object WeightedLeastSquares {
439439

440440
/**
441441
* Weighted population standard deviation of labels.
442-
* We prevent variance from negative value caused by numerical error.
443442
*/
444-
def bStd: Double = math.sqrt(math.max(bbSum / wSum - bBar * bBar, 0.0))
443+
def bStd: Double = {
444+
// We prevent variance from negative value caused by numerical error.
445+
val variance = math.max(bbSum / wSum - bBar * bBar, 0.0)
446+
math.sqrt(variance)
447+
}
445448

446449
/**
447450
* Weighted mean of (label * features).

0 commit comments

Comments
 (0)