I am trying to use ChiSqSelector to determine the best features for a Spark 2.2 LSVCModel, thus:
import org.apache.spark.ml.feature.ChiSqSelector
val chiSelector = new ChiSqSelector().setNumTopFeatures(5).
setFeaturesCol("features").
setLabelCol("label").setOutputCol("selectedFeatures")
val pipeline = new Pipeline().setStages(Array(labelIndexer, monthIndexer, hashingTF
, idf, va, featureIndexer, chiSelector, lsvc, labelConverter))
val model = pipeline.fit(training)
val importantFeatures = model.selectedFeatures
import org.apache.spark.ml.classification.LinearSVCModel
val LSVCModel= model.stages(6).asInstanceOf[org.apache.spark.ml.classification.
LinearSVCModel]
val importantFeatures = LSVCModel.selectedFeatures
which gives the error:
<console>:180: error: value selectedFeatures is not a member of
org.apache.spark.ml.classification.LinearSVCModel
val importantFeatures = LSVCModel.selectedFeatures
Is it possible to use ChiSqSelector with this model? If not, is there an alternative?