Skip to content

Commit 1d2f67f

Browse files
author
Peng, Meng
committed
add javadoc
1 parent 6cc4c92 commit 1d2f67f

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

mllib/src/main/scala/org/apache/spark/ml/feature/ChiSqSelector.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ private[feature] trait ChiSqSelectorParams extends Params
9090
/**
9191
* Chi-Squared feature selection, which selects categorical features to use for predicting a
9292
* categorical label.
93+
* The selector supports three selection methods: KBest, Percentile and FPR.
94+
* By default, the selection method is KBest, the default number of top features is 50.
95+
* User can use setNumTopFeatures, setPercentile and setAlpha to set different selection methods.
9396
*/
9497
@Since("1.6.0")
9598
final class ChiSqSelector @Since("1.6.0") (@Since("1.6.0") override val uid: String)
@@ -99,7 +102,7 @@ final class ChiSqSelector @Since("1.6.0") (@Since("1.6.0") override val uid: Str
99102
def this() = this(Identifiable.randomUID("chiSqSelector"))
100103

101104
/** @group setParam */
102-
@Since("2.1.0")
105+
@Since("1.6.0")
103106
def setNumTopFeatures(value: Int): this.type = {
104107
set(selectorType, ChiSqSelectorType.KBest.toString)
105108
set(numTopFeatures, value)

mllib/src/main/scala/org/apache/spark/mllib/feature/ChiSqSelector.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,27 @@ object ChiSqSelectorModel extends Loader[ChiSqSelectorModel] {
166166

167167
/**
168168
* Creates a ChiSquared feature selector.
169+
* The selector supports three selection methods: KBest, Percentile and FPR.
170+
* By default, the selection method is KBest, the default number of top features is 50.
171+
* User can use setNumTopFeatures, setPercentile and setAlpha to set different selection methods.
169172
*/
170-
@Since("2.1.0")
173+
@Since("1.3.0")
171174
class ChiSqSelector @Since("2.1.0") () extends Serializable {
172175
var numTopFeatures: Int = 50
173176
var percentile: Double = 0.1
174177
var alpha: Double = 0.05
175178
var selectorType = ChiSqSelectorType.KBest
176179

180+
/**
181+
* The is the same to call this() and setNumTopFeatures(numTopFeatures)
182+
*/
177183
@Since("1.3.0")
178184
def this(numTopFeatures: Int) {
179185
this()
180186
this.numTopFeatures = numTopFeatures
181187
}
182188

183-
@Since("2.1.0")
189+
@Since("1.6.0")
184190
def setNumTopFeatures(value: Int): this.type = {
185191
numTopFeatures = value
186192
selectorType = ChiSqSelectorType.KBest

python/pyspark/mllib/feature.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ class ChiSqSelector(object):
310310
311311
.. versionadded:: 1.4.0
312312
"""
313-
def __init__(self):
314-
self.numTopFeatures = 50
313+
def __init__(self, numTopFeatures=50):
314+
self.numTopFeatures = numTopFeatures
315315
self.selectorType = ChiSqSelectorType.KBest
316316

317317
@since('2.1.0')

0 commit comments

Comments
 (0)