Skip to content

Commit

Permalink
minor code style updates
Browse files Browse the repository at this point in the history
  • Loading branch information
manishamde committed Mar 7, 2014
1 parent cd2c2b4 commit eb8fcbe
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package org.apache.spark.mllib.tree

import org.apache.spark.SparkContext._
import scala.util.control.Breaks._
import org.apache.spark.SparkContext._
import org.apache.spark.rdd.RDD
import org.apache.spark.mllib.tree.model._
import org.apache.spark.{SparkContext, Logging}
Expand Down Expand Up @@ -101,7 +101,6 @@ class DecisionTree private(val strategy: Strategy) extends Serializable with Log
val decisionTreeModel = {
return new DecisionTreeModel(topNode, strategy.algo)
}

return decisionTreeModel
}

Expand Down Expand Up @@ -538,10 +537,10 @@ object DecisionTree extends Serializable with Logging {
}

if (leftCount == 0) {
return new InformationGainStats(0,topImpurity,Double.MinValue,topImpurity,1)
return new InformationGainStats(0, topImpurity, Double.MinValue, topImpurity,1)
}
if (rightCount == 0) {
return new InformationGainStats(0,topImpurity,topImpurity,Double.MinValue,0)
return new InformationGainStats(0, topImpurity, topImpurity, Double.MinValue,0)
}

val leftImpurity = strategy.impurity.calculate(left0Count, left1Count)
Expand All @@ -561,7 +560,7 @@ object DecisionTree extends Serializable with Logging {
//val predict = leftCount / (leftCount + rightCount)
val predict = (left1Count + right1Count) / (leftCount + rightCount)

new InformationGainStats(gain,impurity,leftImpurity,rightImpurity,predict)
new InformationGainStats(gain, impurity, leftImpurity, rightImpurity, predict)
}
case Regression => {
val leftCount = leftNodeAgg(featureIndex)(3 * splitIndex)
Expand All @@ -584,12 +583,12 @@ object DecisionTree extends Serializable with Logging {
}

if (leftCount == 0) {
return new InformationGainStats(0,topImpurity,Double.MinValue,topImpurity,
return new InformationGainStats(0, topImpurity, Double.MinValue, topImpurity,
rightSum/rightCount)
}
if (rightCount == 0) {
return new InformationGainStats(0,topImpurity,topImpurity,
Double.MinValue,leftSum/leftCount)
return new InformationGainStats(0, topImpurity ,topImpurity,
Double.MinValue, leftSum/leftCount)
}

val leftImpurity = strategy.impurity.calculate(leftCount, leftSum, leftSumSquares)
Expand Down Expand Up @@ -1024,7 +1023,4 @@ object DecisionTree extends Serializable with Logging {
.mean()
meanSumOfSquares
}



}

0 comments on commit eb8fcbe

Please sign in to comment.