Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1950#discussion_r16279812
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala ---
    @@ -689,37 +631,26 @@ object DecisionTree extends Serializable with Logging 
{
          *            bin index for this labeledPoint
          *            (or InvalidBinIndex if labeledPoint is not handled by 
this node)
          */
    -    def findBinsForLevel(labeledPoint: LabeledPoint): Array[Double] = {
    +    def findBinsForLevel(treePoint: TreePoint): Array[Double] = {
           // Calculate bin index and label per feature per node.
           val arr = new Array[Double](1 + (numFeatures * numNodes))
           // First element of the array is the label of the instance.
    -      arr(0) = labeledPoint.label
    +      arr(0) = treePoint.label
           // Iterate over nodes.
           var nodeIndex = 0
           while (nodeIndex < numNodes) {
             val parentFilters = findParentFilters(nodeIndex)
             // Find out whether the sample qualifies for the particular node.
    -        val sampleValid = isSampleValid(parentFilters, labeledPoint)
    +        val sampleValid = isSampleValid(parentFilters, treePoint)
             val shift = 1 + numFeatures * nodeIndex
             if (!sampleValid) {
               // Mark one bin as -1 is sufficient.
               arr(shift) = InvalidBinIndex
             } else {
               var featureIndex = 0
    +          // TODO: Vectorize this
               while (featureIndex < numFeatures) {
    -            val featureInfo = 
strategy.categoricalFeaturesInfo.get(featureIndex)
    -            val isFeatureContinuous = featureInfo.isEmpty
    -            if (isFeatureContinuous) {
    -              arr(shift + featureIndex)
    -                = findBin(featureIndex, labeledPoint, isFeatureContinuous, 
false)
    -            } else {
    -              val featureCategories = featureInfo.get
    -              val isSpaceSufficientForAllCategoricalSplits
    -                = numBins > math.pow(2, featureCategories.toInt - 1) - 1
    -              arr(shift + featureIndex)
    -                = findBin(featureIndex, labeledPoint, isFeatureContinuous,
    -                isSpaceSufficientForAllCategoricalSplits)
    -            }
    +            arr(shift + featureIndex) = treePoint.features(featureIndex)
    --- End diff --
    
    use `Array.copy(treePoint.features, 0, arr, shift, numFeatures)` to replace 
the while loop?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to