Skip to content

Commit 10f7599

Browse files
zjffduNick Pentreath
authored andcommitted
[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 <[email protected]> Closes #13540 from zjffdu/SPARK-15788. (cherry picked from commit e594b49) Signed-off-by: Nick Pentreath <[email protected]>
1 parent eb9e8fc commit 10f7599

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

python/pyspark/ml/feature.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,8 @@ class IDF(JavaEstimator, HasInputCol, HasOutputCol, JavaMLReadable, JavaMLWritab
585585
... (DenseVector([0.0, 1.0]),), (DenseVector([3.0, 0.2]),)], ["tf"])
586586
>>> idf = IDF(minDocFreq=3, inputCol="tf", outputCol="idf")
587587
>>> model = idf.fit(df)
588+
>>> model.idf
589+
DenseVector([0.0, 0.0])
588590
>>> model.transform(df).head().idf
589591
DenseVector([0.0, 0.0])
590592
>>> idf.setParams(outputCol="freqs").fit(df).transform(df).collect()[1].freqs
@@ -658,6 +660,14 @@ class IDFModel(JavaModel, JavaMLReadable, JavaMLWritable):
658660
.. versionadded:: 1.4.0
659661
"""
660662

663+
@property
664+
@since("2.0.0")
665+
def idf(self):
666+
"""
667+
Returns the IDF vector.
668+
"""
669+
return self._call_java("idf")
670+
661671

662672
@inherit_doc
663673
class MaxAbsScaler(JavaEstimator, HasInputCol, HasOutputCol, JavaMLReadable, JavaMLWritable):

0 commit comments

Comments
 (0)