Skip to content

Commit

Permalink
minor change to variance calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
MechCoder committed Jun 29, 2016
1 parent e8b8914 commit af1ff66
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,8 @@ object Variance extends Impurity {
val rightSumSquares = parentSumSquares - leftSumSquares

val parentImpurity = (parentSumSquares - (parentSum * parentSum) / totalCount) / totalCount
val leftImpurity = (leftSumSquares - (leftSum * leftSum) / leftCount) / leftCount
val rightImpurity = (rightSumSquares - (rightSum * rightSum) / rightCount) / leftCount

val leftWeighted = leftImpurity * leftCount / totalCount
val rightWeighted = rightImpurity * rightCount / totalCount
val leftWeighted = (leftSumSquares - (leftSum * leftSum) / leftCount) / totalCount
val rightWeighted = (rightSumSquares - (rightSum * rightSum) / rightCount) / totalCount
val gain = parentImpurity - leftWeighted - rightWeighted

if (gain < minInfoGain) {
Expand Down

0 comments on commit af1ff66

Please sign in to comment.