1717
1818package org .apache .spark .mllib .tree
1919
20- import org .apache .spark .SparkContext ._
2120import scala .util .control .Breaks ._
21+ import org .apache .spark .SparkContext ._
2222import org .apache .spark .rdd .RDD
2323import org .apache .spark .mllib .tree .model ._
2424import org .apache .spark .{SparkContext , Logging }
@@ -101,7 +101,6 @@ class DecisionTree private(val strategy: Strategy) extends Serializable with Log
101101 val decisionTreeModel = {
102102 return new DecisionTreeModel (topNode, strategy.algo)
103103 }
104-
105104 return decisionTreeModel
106105 }
107106
@@ -538,10 +537,10 @@ object DecisionTree extends Serializable with Logging {
538537 }
539538
540539 if (leftCount == 0 ) {
541- return new InformationGainStats (0 ,topImpurity,Double .MinValue ,topImpurity,1 )
540+ return new InformationGainStats (0 , topImpurity, Double .MinValue , topImpurity,1 )
542541 }
543542 if (rightCount == 0 ) {
544- return new InformationGainStats (0 ,topImpurity,topImpurity,Double .MinValue ,0 )
543+ return new InformationGainStats (0 , topImpurity, topImpurity, Double .MinValue ,0 )
545544 }
546545
547546 val leftImpurity = strategy.impurity.calculate(left0Count, left1Count)
@@ -561,7 +560,7 @@ object DecisionTree extends Serializable with Logging {
561560 // val predict = leftCount / (leftCount + rightCount)
562561 val predict = (left1Count + right1Count) / (leftCount + rightCount)
563562
564- new InformationGainStats (gain,impurity,leftImpurity,rightImpurity,predict)
563+ new InformationGainStats (gain, impurity, leftImpurity, rightImpurity, predict)
565564 }
566565 case Regression => {
567566 val leftCount = leftNodeAgg(featureIndex)(3 * splitIndex)
@@ -584,12 +583,12 @@ object DecisionTree extends Serializable with Logging {
584583 }
585584
586585 if (leftCount == 0 ) {
587- return new InformationGainStats (0 ,topImpurity,Double .MinValue ,topImpurity,
586+ return new InformationGainStats (0 , topImpurity, Double .MinValue , topImpurity,
588587 rightSum/ rightCount)
589588 }
590589 if (rightCount == 0 ) {
591- return new InformationGainStats (0 ,topImpurity,topImpurity,
592- Double .MinValue ,leftSum/ leftCount)
590+ return new InformationGainStats (0 , topImpurity ,topImpurity,
591+ Double .MinValue , leftSum/ leftCount)
593592 }
594593
595594 val leftImpurity = strategy.impurity.calculate(leftCount, leftSum, leftSumSquares)
@@ -1024,7 +1023,4 @@ object DecisionTree extends Serializable with Logging {
10241023 .mean()
10251024 meanSumOfSquares
10261025 }
1027-
1028-
1029-
10301026}
0 commit comments