diff options
author | Yuhao Yang <hhbyyh@gmail.com> | 2016-04-20 11:45:08 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-04-20 11:45:08 +0100 |
commit | ed9d80385486cd39a84a689ef467795262af919a (patch) | |
tree | 954f979137825630508203428c0f6e6869373138 /examples/src/main/python/ml | |
parent | 17db4bfeaa0074298db622db38a5b0459518c4a9 (diff) | |
download | spark-ed9d80385486cd39a84a689ef467795262af919a.tar.gz spark-ed9d80385486cd39a84a689ef467795262af919a.tar.bz2 spark-ed9d80385486cd39a84a689ef467795262af919a.zip |
[SPARK-14635][ML] Documentation and Examples for TF-IDF only refer to HashingTF
## What changes were proposed in this pull request?
Currently, the docs for TF-IDF only refer to using HashingTF with IDF. However, CountVectorizer can also be used. We should probably amend the user guide and examples to show this.
## How was this patch tested?
unit tests and doc generation
Author: Yuhao Yang <hhbyyh@gmail.com>
Closes #12454 from hhbyyh/tfdoc.
Diffstat (limited to 'examples/src/main/python/ml')
-rw-r--r-- | examples/src/main/python/ml/tf_idf_example.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/examples/src/main/python/ml/tf_idf_example.py b/examples/src/main/python/ml/tf_idf_example.py index c92313378e..141324d458 100644 --- a/examples/src/main/python/ml/tf_idf_example.py +++ b/examples/src/main/python/ml/tf_idf_example.py @@ -37,6 +37,8 @@ if __name__ == "__main__": wordsData = tokenizer.transform(sentenceData) hashingTF = HashingTF(inputCol="words", outputCol="rawFeatures", numFeatures=20) featurizedData = hashingTF.transform(wordsData) + # alternatively, CountVectorizer can also be used to get term frequency vectors + idf = IDF(inputCol="rawFeatures", outputCol="features") idfModel = idf.fit(featurizedData) rescaledData = idfModel.transform(featurizedData) |