Github user holdenk commented on a diff in the pull request:
https://github.com/apache/spark/pull/17978#discussion_r117612782
--- Diff: python/pyspark/ml/feature.py ---
@@ -2111,26 +2112,45 @@ class StringIndexer(JavaEstimator, HasInputCol,
HasOutputCol, HasHandleInvalid,
>>> loadedInverter = IndexToString.load(indexToStringPath)
>>> loadedInverter.getLabels() == inverter.getLabels()
True
+ >>> stringIndexer.getStringOrderType()
+ 'frequencyDesc'
+ >>> stringIndexer = StringIndexer(inputCol="label",
outputCol="indexed", handleInvalid='error',
+ ... stringOrderType="alphabetDesc")
+ >>> model = stringIndexer.fit(stringIndDf)
+ >>> td = model.transform(stringIndDf)
+ >>> sorted(set([(i[0], i[1]) for i in td.select(td.id,
td.indexed).collect()]),
+ ... key=lambda x: x[0])
+ [(0, 2.0), (1, 1.0), (2, 0.0), (3, 2.0), (4, 2.0), (5, 0.0)]
.. versionadded:: 1.4.0
"""
+ stringOrderType = Param(Params._dummy(), "stringOrderType",
+ "How to order labels of string column. The
first label after " +
+ "ordering is assigned an index of 0. Supported
options: " +
+ "frequencyDesc, frequencyAsc, alphabetDesc,
alphabetAsc.",
--- End diff --
I know were mixed on doing this, but I like including the default value in
the docstring, makes the documentation closer to the Scala doc and makes it
easier to read without having to refer to the ScalaDoc.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]