Skip to content

Commit 95c479d

Browse files
committed
* Fixed typo in tree suite test "do not choose split that does not satisfy min instance per node requirements"
* small style fixes
1 parent e2628b6 commit 95c479d

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ object DecisionTree extends Serializable with Logging {
929929
}
930930
}.maxBy(_._2.gain)
931931

932-
require(predict.isDefined, "must calculate predict for each node")
932+
assert(predict.isDefined, "must calculate predict for each node")
933933

934934
(bestSplit, bestSplitStats, predict.get)
935935
}

mllib/src/main/scala/org/apache/spark/mllib/tree/model/Predict.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,14 @@
1717

1818
package org.apache.spark.mllib.tree.model
1919

20-
import org.apache.spark.annotation.DeveloperApi
21-
2220
/**
23-
* :: DeveloperApi ::
2421
* Predicted value for a node
2522
* @param predict predicted value
2623
* @param prob probability of the label (classification only)
2724
*/
28-
@DeveloperApi
2925
private[tree] class Predict(
3026
val predict: Double,
31-
val prob: Double = 0.0) extends Serializable{
27+
val prob: Double = 0.0) extends Serializable {
3228

3329
override def toString = {
3430
"predict = %f, prob = %f".format(predict, prob)

mllib/src/test/scala/org/apache/spark/mllib/tree/DecisionTreeSuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,8 @@ class DecisionTreeSuite extends FunSuite with LocalSparkContext {
706706
assert(bestInfoStats == InformationGainStats.invalidInformationGainStats)
707707
}
708708

709-
test("don't choose split that doesn't satisfy min instance per node requirements") {
710-
// if a split doesn't satisfy min instances per node requirements,
709+
test("do not choose split that does not satisfy min instance per node requirements") {
710+
// if a split does not satisfy min instances per node requirements,
711711
// this split is invalid, even though the information gain of split is large.
712712
val arr = new Array[LabeledPoint](4)
713713
arr(0) = new LabeledPoint(0.0, Vectors.dense(0.0, 1.0))
@@ -727,7 +727,7 @@ class DecisionTreeSuite extends FunSuite with LocalSparkContext {
727727

728728
assert(bestSplits.length == 1)
729729
val bestSplit = bestSplits(0)._1
730-
val bestSplitStats = bestSplits(0)._1
730+
val bestSplitStats = bestSplits(0)._2
731731
assert(bestSplit.feature == 1)
732732
assert(bestSplitStats != InformationGainStats.invalidInformationGainStats)
733733
}

0 commit comments

Comments
 (0)