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

    https://github.com/apache/spark/pull/3320#discussion_r20676265
  
    --- Diff: python/pyspark/mllib/tree.py ---
    @@ -181,8 +182,206 @@ def trainRegressor(data, categoricalFeaturesInfo,
             >>> model.predict(rdd).collect()
             [1.0, 0.0]
             """
    -        return DecisionTree._train(data, "regression", 0, 
categoricalFeaturesInfo,
    -                                   impurity, maxDepth, maxBins, 
minInstancesPerNode, minInfoGain)
    +        return cls._train(data, "regression", 0, categoricalFeaturesInfo,
    +                          impurity, maxDepth, maxBins, 
minInstancesPerNode, minInfoGain)
    +
    +
    +class RandomForestModel(JavaModelWrapper):
    +    """
    +    Represents a random forest model.
    +
    +    EXPERIMENTAL: This is an experimental API.
    +                  It will probably be modified in future.
    +    """
    +    def predict(self, x):
    +        """
    +        Predict values for a single data point or an RDD of points using
    +        the model trained.
    +        """
    +        if isinstance(x, RDD):
    +            return self.call("predict", x.map(_convert_to_vector))
    +
    +        else:
    +            return self.call("predict", _convert_to_vector(x))
    +
    +    def numTrees(self):
    +        """
    +        Get number of trees in forest.
    +        """
    +        return self.call("numTrees")
    +
    +    def totalNumNodes(self):
    +        """
    +        Get total number of nodes, summed over all trees in the forest.
    +        """
    +        return self.call("totalNumNodes")
    +
    +    def __repr__(self):
    +        """ Summary of model """
    +        return self._java_model.toString()
    +
    +    def toDebugString(self):
    +        """ Full model """
    +        return self._java_model.toDebugString()
    +
    +
    +class RandomForest(object):
    +    """
    +    Learning algorithm for a random forest model for classification or 
regression.
    +
    +    EXPERIMENTAL: This is an experimental API.
    +                  It will probably be modified in future.
    +    """
    +
    +    supportedFeatureSubsetStrategies = ("auto", "all", "sqrt", "log2", 
"onethird")
    +
    +    @classmethod
    +    def _train(cls, data, type, numClasses, features, impurity, maxDepth, 
maxBins,
    --- End diff --
    
    type --> algo
    features --> categoricalFeaturesInfo


---
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