spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkbradley <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-5094][MLlib] Add Python API for Gradien...
Date Sun, 25 Jan 2015 00:34:52 GMT
Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3951#discussion_r23500734
  
    --- Diff: python/pyspark/mllib/tree.py ---
    @@ -24,7 +24,41 @@
     from pyspark.mllib.linalg import _convert_to_vector
     from pyspark.mllib.regression import LabeledPoint
     
    -__all__ = ['DecisionTreeModel', 'DecisionTree', 'RandomForestModel', 'RandomForest']
    +__all__ = ['TreeEnsembleModel', 'DecisionTreeModel', 'DecisionTree', 'RandomForestModel',
    +           'RandomForest', 'GradientBoostedTrees']
    +
    +
    +class TreeEnsembleModel(JavaModelWrapper):
    +    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.
    --- End diff --
    
    "forest" --> ensemble"


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message