Skip to content

Commit

Permalink
Fix Python 3 Error
Browse files Browse the repository at this point in the history
  • Loading branch information
MechCoder committed Jun 30, 2015
1 parent 47d7023 commit 6d16ad8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.spark.ml.tree

import org.apache.spark.mllib.linalg.{Vectors, Vector}

/**
* Abstraction for Decision Tree models.
Expand Down Expand Up @@ -70,6 +71,10 @@ private[ml] trait TreeEnsembleModel {
/** Weights for each tree, zippable with [[trees]] */
def treeWeights: Array[Double]

/** Weights used by the python wrappers. */
// Note: An array cannot be returned directly due to serialization problems.
def pyTreeWeights: Vector = Vectors.dense(treeWeights)

/** Summary of the model */
override def toString: String = {
// Implementing classes should generally override this method to be more descriptive.
Expand Down
3 changes: 2 additions & 1 deletion python/pyspark/ml/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ class TreeEnsembleModels(JavaModel):

@property
def treeWeights(self):
return list(self._call_java("treeWeights"))
"""Return the weights for each tree"""
return list(self._call_java("pyTreeWeights"))

def __repr__(self):
return self._call_java("toString")
Expand Down

0 comments on commit 6d16ad8

Please sign in to comment.