Repository: spark
Updated Branches:
  refs/heads/branch-2.0 eb9e8fc09 -> 10f759947


[SPARK-15788][PYSPARK][ML] PySpark IDFModel missing "idf" property

## What changes were proposed in this pull request?

add method idf to IDF in pyspark

## How was this patch tested?

add unit test

Author: Jeff Zhang <zjf...@apache.org>

Closes #13540 from zjffdu/SPARK-15788.

(cherry picked from commit e594b492836988ef3d9487b511368c70169d1ecd)
Signed-off-by: Nick Pentreath <ni...@za.ibm.com>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/10f75994
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/10f75994
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/10f75994

Branch: refs/heads/branch-2.0
Commit: 10f7599471dd0d2b5efb49c5e1664fa24dfee074
Parents: eb9e8fc
Author: Jeff Zhang <zjf...@apache.org>
Authored: Thu Jun 9 09:54:38 2016 -0700
Committer: Nick Pentreath <ni...@za.ibm.com>
Committed: Thu Jun 9 09:54:47 2016 -0700

----------------------------------------------------------------------
 python/pyspark/ml/feature.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/10f75994/python/pyspark/ml/feature.py
----------------------------------------------------------------------
diff --git a/python/pyspark/ml/feature.py b/python/pyspark/ml/feature.py
index 1aff2e5..ebe1300 100755
--- a/python/pyspark/ml/feature.py
+++ b/python/pyspark/ml/feature.py
@@ -585,6 +585,8 @@ class IDF(JavaEstimator, HasInputCol, HasOutputCol, 
JavaMLReadable, JavaMLWritab
     ...     (DenseVector([0.0, 1.0]),), (DenseVector([3.0, 0.2]),)], ["tf"])
     >>> idf = IDF(minDocFreq=3, inputCol="tf", outputCol="idf")
     >>> model = idf.fit(df)
+    >>> model.idf
+    DenseVector([0.0, 0.0])
     >>> model.transform(df).head().idf
     DenseVector([0.0, 0.0])
     >>> 
idf.setParams(outputCol="freqs").fit(df).transform(df).collect()[1].freqs
@@ -658,6 +660,14 @@ class IDFModel(JavaModel, JavaMLReadable, JavaMLWritable):
     .. versionadded:: 1.4.0
     """
 
+    @property
+    @since("2.0.0")
+    def idf(self):
+        """
+        Returns the IDF vector.
+        """
+        return self._call_java("idf")
+
 
 @inherit_doc
 class MaxAbsScaler(JavaEstimator, HasInputCol, HasOutputCol, JavaMLReadable, 
JavaMLWritable):


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

Reply via email to