huaxingao commented on a change in pull request #27978: [SPARK-31127][ML]
Implement abstract Selector
URL: https://github.com/apache/spark/pull/27978#discussion_r396063627
##########
File path: mllib/src/main/scala/org/apache/spark/ml/feature/ChiSqSelector.scala
##########
@@ -153,103 +46,69 @@ private[feature] trait ChiSqSelectorParams extends Params
*/
@Since("1.6.0")
final class ChiSqSelector @Since("1.6.0") (@Since("1.6.0") override val uid:
String)
- extends Estimator[ChiSqSelectorModel] with ChiSqSelectorParams with
DefaultParamsWritable {
+ extends PSelector[ChiSqSelectorModel] {
@Since("1.6.0")
def this() = this(Identifiable.randomUID("chiSqSelector"))
/** @group setParam */
@Since("1.6.0")
- def setNumTopFeatures(value: Int): this.type = set(numTopFeatures, value)
+ override def setNumTopFeatures(value: Int): this.type =
super.setNumTopFeatures(value)
/** @group setParam */
@Since("2.1.0")
- def setPercentile(value: Double): this.type = set(percentile, value)
+ override def setPercentile(value: Double): this.type =
super.setPercentile(value)
/** @group setParam */
@Since("2.1.0")
- def setFpr(value: Double): this.type = set(fpr, value)
+ override def setFpr(value: Double): this.type = super.setFpr(value)
/** @group setParam */
@Since("2.2.0")
- def setFdr(value: Double): this.type = set(fdr, value)
+ override def setFdr(value: Double): this.type = super.setFdr(value)
/** @group setParam */
@Since("2.2.0")
- def setFwe(value: Double): this.type = set(fwe, value)
+ override def setFwe(value: Double): this.type = super.setFwe(value)
/** @group setParam */
@Since("2.1.0")
- def setSelectorType(value: String): this.type = set(selectorType, value)
+ override def setSelectorType(value: String): this.type =
super.setSelectorType(value)
/** @group setParam */
@Since("1.6.0")
- def setFeaturesCol(value: String): this.type = set(featuresCol, value)
+ override def setFeaturesCol(value: String): this.type =
super.setFeaturesCol(value)
/** @group setParam */
@Since("1.6.0")
- def setOutputCol(value: String): this.type = set(outputCol, value)
+ override def setOutputCol(value: String): this.type =
super.setOutputCol(value)
Review comment:
seems I have to override these methods. Otherwise, I have error like this
```
/Users/hgao/myspark/spark/examples/src/main/java/org/apache/spark/examples/ml/JavaChiSqSelectorExample.java:63:
error: incompatible types: Selector<ChiSqSelectorModel> cannot be converted to
ChiSqSelector
[error] .setOutputCol("selectedFeatures");
[error] ^
[error] (examples/compile:compileIncremental) javac returned nonzero exit
code
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]