Skip to content

Commit cbd9f14

Browse files
committed
modified scala.math to math
1 parent dad9652 commit cbd9f14

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class DecisionTree (private val strategy: Strategy) extends Serializable with Lo
6060
// depth of the decision tree
6161
val maxDepth = strategy.maxDepth
6262
// the max number of nodes possible given the depth of the tree
63-
val maxNumNodes = scala.math.pow(2, maxDepth).toInt - 1
63+
val maxNumNodes = math.pow(2, maxDepth).toInt - 1
6464
// Initialize an array to hold filters applied to points for each node.
6565
val filters = new Array[List[Filter]](maxNumNodes)
6666
// The filter at the top node is an empty list.
@@ -85,11 +85,11 @@ class DecisionTree (private val strategy: Strategy) extends Serializable with Lo
8585
}
8686
logDebug("numElementsPerNode = " + numElementsPerNode)
8787
val arraySizePerNode = 8 * numElementsPerNode // approx. memory usage for bin aggregate array
88-
val maxNumberOfNodesPerGroup = scala.math.max(maxMemoryUsage / arraySizePerNode, 1)
88+
val maxNumberOfNodesPerGroup = math.max(maxMemoryUsage / arraySizePerNode, 1)
8989
logDebug("maxNumberOfNodesPerGroup = " + maxNumberOfNodesPerGroup)
9090
// nodes at a level is 2^(level-1). level is zero indexed.
91-
val maxLevelForSingleGroup = scala.math.max(
92-
(scala.math.log(maxNumberOfNodesPerGroup) / scala.math.log(2)).floor.toInt - 1, 0)
91+
val maxLevelForSingleGroup = math.max(
92+
(math.log(maxNumberOfNodesPerGroup) / math.log(2)).floor.toInt - 1, 0)
9393
logDebug("max level for single group = " + maxLevelForSingleGroup)
9494

9595
/*
@@ -120,7 +120,7 @@ class DecisionTree (private val strategy: Strategy) extends Serializable with Lo
120120
filters)
121121
logDebug("final best split = " + nodeSplitStats._1)
122122
}
123-
require(scala.math.pow(2, level) == splitsStatsForLevel.length)
123+
require(math.pow(2, level) == splitsStatsForLevel.length)
124124
// Check whether all the nodes at the current level at leaves.
125125
val allLeaf = splitsStatsForLevel.forall(_._2.gain <= 0)
126126
logDebug("all leaf = " + allLeaf)
@@ -153,7 +153,7 @@ class DecisionTree (private val strategy: Strategy) extends Serializable with Lo
153153
nodes: Array[Node]): Unit = {
154154
val split = nodeSplitStats._1
155155
val stats = nodeSplitStats._2
156-
val nodeIndex = scala.math.pow(2, level).toInt - 1 + index
156+
val nodeIndex = math.pow(2, level).toInt - 1 + index
157157
val isLeaf = (stats.gain <= 0) || (level == strategy.maxDepth - 1)
158158
val node = new Node(nodeIndex, stats.predict, isLeaf, Some(split), None, None, Some(stats))
159159
logDebug("Node = " + node)
@@ -174,7 +174,7 @@ class DecisionTree (private val strategy: Strategy) extends Serializable with Lo
174174
var i = 0
175175
while (i <= 1) {
176176
// Calculate the index of the node from the node level and the index at the current level.
177-
val nodeIndex = scala.math.pow(2, level + 1).toInt - 1 + 2 * index + i
177+
val nodeIndex = math.pow(2, level + 1).toInt - 1 + 2 * index + i
178178
if (level < maxDepth - 1) {
179179
val impurity = if (i == 0) {
180180
nodeSplitStats._2.leftImpurity
@@ -300,7 +300,7 @@ object DecisionTree extends Serializable with Logging {
300300
maxLevelForSingleGroup: Int): Array[(Split, InformationGainStats)] = {
301301
// split into groups to avoid memory overflow during aggregation
302302
if (level > maxLevelForSingleGroup) {
303-
val numGroups = scala.math.pow(2, (level - maxLevelForSingleGroup)).toInt
303+
val numGroups = math.pow(2, (level - maxLevelForSingleGroup)).toInt
304304
logDebug("numGroups = " + numGroups)
305305
var groupIndex = 0
306306
var bestSplits = new Array[(Split, InformationGainStats)](0)
@@ -366,7 +366,7 @@ object DecisionTree extends Serializable with Logging {
366366
*/
367367

368368
// common calculations for multiple nested methods
369-
val numNodes = scala.math.pow(2, level).toInt / numGroups
369+
val numNodes = math.pow(2, level).toInt / numGroups
370370
logDebug("numNodes = " + numNodes)
371371
// Find the number of features by looking at the first sample.
372372
val numFeatures = input.first().features.size
@@ -382,7 +382,7 @@ object DecisionTree extends Serializable with Logging {
382382
if (level == 0) {
383383
List[Filter]()
384384
} else {
385-
val nodeFilterIndex = scala.math.pow(2, level).toInt - 1 + nodeIndex + groupShift
385+
val nodeFilterIndex = math.pow(2, level).toInt - 1 + nodeIndex + groupShift
386386
filters(nodeFilterIndex)
387387
}
388388
}
@@ -951,7 +951,7 @@ object DecisionTree extends Serializable with Logging {
951951
// Iterating over all nodes at this level
952952
var node = 0
953953
while (node < numNodes) {
954-
val nodeImpurityIndex = scala.math.pow(2, level).toInt - 1 + node + groupShift
954+
val nodeImpurityIndex = math.pow(2, level).toInt - 1 + node + groupShift
955955
val binsForNode: Array[Double] = getBinDataForNode(node)
956956
logDebug("nodeImpurityIndex = " + nodeImpurityIndex)
957957
val parentNodeImpurity = parentImpurities(nodeImpurityIndex)

0 commit comments

Comments
 (0)