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

    https://github.com/apache/spark/pull/2435#discussion_r18063715
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala ---
    @@ -465,43 +329,60 @@ object DecisionTree extends Serializable with Logging 
{
        * @param agg  Array storing aggregate calculation, with a set of 
sufficient statistics for
        *             each (node, feature, bin).
        * @param treePoint  Data point being aggregated.
    -   * @param nodeIndex  Node corresponding to treePoint. Indexed from 0 at 
start of (level, group).
    +   * @param nodeIndex  Node corresponding to treePoint.  agg is indexed in 
[0, numNodes).
        * @param bins possible bins for all features, indexed 
(numFeatures)(numBins)
        * @param unorderedFeatures  Set of indices of unordered features.
    +   * @param instanceWeight  Weight (importance) of instance in dataset.
        */
       private def mixedBinSeqOp(
           agg: DTStatsAggregator,
           treePoint: TreePoint,
           nodeIndex: Int,
           bins: Array[Array[Bin]],
    -      unorderedFeatures: Set[Int]): Unit = {
    -    // Iterate over all features.
    -    val numFeatures = treePoint.binnedFeatures.size
    +      unorderedFeatures: Set[Int],
    +      instanceWeight: Double,
    +      featuresForNode: Option[Array[Int]]): Unit = {
    +    val numFeaturesPerNode = if (featuresForNode.nonEmpty) {
    +      // Use subsampled features
    +      featuresForNode.get.size
    +    } else {
    +      // Use all features
    +      agg.metadata.numFeatures
    +    }
         val nodeOffset = agg.getNodeOffset(nodeIndex)
    -    var featureIndex = 0
    -    while (featureIndex < numFeatures) {
    +    // Iterate over features.
    +    var featureIndexIdx = 0
    +    while (featureIndexIdx < numFeaturesPerNode) {
    +      val featureIndex = if (featuresForNode.nonEmpty) {
    +        featuresForNode.get.apply(featureIndexIdx)
    --- End diff --
    
    minor: apply is a bit awkward since you normally use the syntactic sugar () 
to access array elements.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to