zhengruifeng commented on a change in pull request #27679: [SPARK-30776][ML] Support FValueSelector for continuous features and continuous labels URL: https://github.com/apache/spark/pull/27679#discussion_r386874061
########## File path: mllib/src/main/scala/org/apache/spark/ml/feature/FValueSelector.scala ########## @@ -0,0 +1,432 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.ml.feature + +import scala.collection.mutable.ArrayBuilder + +import org.apache.hadoop.fs.Path + +import org.apache.spark.annotation.Since +import org.apache.spark.ml._ +import org.apache.spark.ml.attribute._ +import org.apache.spark.ml.linalg._ +import org.apache.spark.ml.param._ +import org.apache.spark.ml.param.shared._ +import org.apache.spark.ml.stat.{FValueTest, SelectionTestResult} +import org.apache.spark.ml.util._ +import org.apache.spark.sql._ +import org.apache.spark.sql.functions._ +import org.apache.spark.sql.types.{DoubleType, StructField, StructType} + + +/** + * Params for [[FValueSelector]] and [[FValueSelectorModel]]. + */ +private[feature] trait FValueSelectorParams extends Params + with HasFeaturesCol with HasOutputCol with HasLabelCol { + + /** Review comment: Nit: "If the number of features is less than numTopFeatures, then this will select all features." I found that `ChiSqSelector` has similar logic, so I guess we can apply a small optimization in the future: check the params before `fit`, if the number of features is less than numTopFeatures (or similar logic based on other params like `fdr==0` ), then directly return model with all feature selected. For now, I think we can just keep current logic. ---------------------------------------------------------------- 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]
