Skip to content

Commit cd2c2b4

Browse files
committed
fixing code style based on feedback
1 parent 63e786b commit cd2c2b4

File tree

17 files changed

+365
-352
lines changed

17 files changed

+365
-352
lines changed

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

Lines changed: 291 additions & 176 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 143 deletions
This file was deleted.

mllib/src/main/scala/org/apache/spark/mllib/tree/configuration/Algo.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
package org.apache.spark.mllib.tree.configuration
1819

1920
/**
@@ -22,4 +23,4 @@ package org.apache.spark.mllib.tree.configuration
2223
object Algo extends Enumeration {
2324
type Algo = Value
2425
val Classification, Regression = Value
25-
}
26+
}

mllib/src/main/scala/org/apache/spark/mllib/tree/configuration/FeatureType.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
package org.apache.spark.mllib.tree.configuration
1819

1920
/**

mllib/src/main/scala/org/apache/spark/mllib/tree/configuration/QuantileStrategy.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
package org.apache.spark.mllib.tree.configuration
1819

1920
/**

mllib/src/main/scala/org/apache/spark/mllib/tree/configuration/Strategy.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
package org.apache.spark.mllib.tree.configuration
1819

1920
import org.apache.spark.mllib.tree.impurity.Impurity
@@ -34,13 +35,13 @@ import org.apache.spark.mllib.tree.configuration.QuantileStrategy._
3435
* zero-indexed.
3536
*/
3637
class Strategy (
37-
val algo : Algo,
38-
val impurity : Impurity,
39-
val maxDepth : Int,
40-
val maxBins : Int = 100,
41-
val quantileCalculationStrategy : QuantileStrategy = Sort,
42-
val categoricalFeaturesInfo : Map[Int,Int] = Map[Int,Int]()) extends Serializable {
38+
val algo: Algo,
39+
val impurity: Impurity,
40+
val maxDepth: Int,
41+
val maxBins: Int = 100,
42+
val quantileCalculationStrategy: QuantileStrategy = Sort,
43+
val categoricalFeaturesInfo: Map[Int,Int] = Map[Int,Int]()) extends Serializable {
4344

44-
var numBins : Int = Int.MinValue
45+
var numBins: Int = Int.MinValue
4546

4647
}

mllib/src/main/scala/org/apache/spark/mllib/tree/impurity/Entropy.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
package org.apache.spark.mllib.tree.impurity
1819

1920
import javax.naming.OperationNotSupportedException

mllib/src/main/scala/org/apache/spark/mllib/tree/impurity/Gini.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
package org.apache.spark.mllib.tree.impurity
1819

1920
import javax.naming.OperationNotSupportedException

mllib/src/main/scala/org/apache/spark/mllib/tree/impurity/Impurity.scala

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,29 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
package org.apache.spark.mllib.tree.impurity
1819

20+
/**
21+
* Trail for calculating information gain
22+
*/
1923
trait Impurity extends Serializable {
2024

25+
/**
26+
* information calculation for binary classification
27+
* @param c0 count of instances with label 0
28+
* @param c1 count of instances with label 1
29+
* @return information value
30+
*/
2131
def calculate(c0 : Double, c1 : Double): Double
2232

23-
def calculate(count : Double, sum : Double, sumSquares : Double) : Double
33+
/**
34+
* information calculation for regression
35+
* @param count number of instances
36+
* @param sum sum of labels
37+
* @param sumSquares summation of squares of the labels
38+
* @return information value
39+
*/
40+
def calculate(count: Double, sum: Double, sumSquares: Double): Double
2441

2542
}

mllib/src/main/scala/org/apache/spark/mllib/tree/impurity/Variance.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
package org.apache.spark.mllib.tree.impurity
1819

1920
import javax.naming.OperationNotSupportedException
@@ -23,7 +24,8 @@ import org.apache.spark.Logging
2324
* Class for calculating variance during regression
2425
*/
2526
object Variance extends Impurity with Logging {
26-
def calculate(c0: Double, c1: Double): Double = throw new OperationNotSupportedException("Variance.calculate")
27+
def calculate(c0: Double, c1: Double): Double
28+
= throw new OperationNotSupportedException("Variance.calculate")
2729

2830
/**
2931
* variance calculation

0 commit comments

Comments
 (0)