You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by yanboliang <gi...@git.apache.org> on 2017/04/28 17:44:24 UTC
[GitHub] spark pull request #17237: [SPARK-19852][PYSPARK][ML] Update Python API setH...
Github user yanboliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/17237#discussion_r113983452
--- Diff: python/pyspark/ml/feature.py ---
@@ -1936,6 +1935,14 @@ class StringIndexer(JavaEstimator, HasInputCol, HasOutputCol, HasHandleInvalid,
>>> sorted(set([(i[0], str(i[1])) for i in itd.select(itd.id, itd.label2).collect()]),
... key=lambda x: x[0])
[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'a'), (4, 'a'), (5, 'c')]
+ >>> testData2 = sc.parallelize([Row(id=0, label="a"), Row(id=1, label="d"),
+ ... Row(id=2, label=None)], 2)
+ >>> dfKeep= spark.createDataFrame(testData2)
+ >>> modelKeep = stringIndexer.setHandleInvalid("keep").fit(stringIndDf)
+ >>> tdK = modelKeep.transform(dfKeep)
+ >>> sorted(set([(i[0], i[1]) for i in tdK.select(tdK.id, tdK.indexed).collect()]),
+ ... key=lambda x: x[0])
+ [(0, 0.0), (1, 3.0), (2, 3.0)]
--- End diff --
Could you move the newly added test to ```tests.py```? We keep the basic doc tests here both for test and example, other tests should be placed at ```tests.py```. Thanks.
---
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