DecisionTreeClassifier.train()无法调用

我在尝试使用DecisionTreeClassifier.train()时出现了以下报错提示:

Error:(218, 41) method train in class DecisionTreeClassifier cannot be accessed in org.apache.spark.ml.classification.DecisionTreeClassifier
Access to protected method train not permitted because
enclosing object FeatureSelection in package core is not a subclass of
class DecisionTreeClassifier in package classification where target is defined
val dt = decisionTreeClassifier.train(trainRdd)

指出由于我的对象 FeatureSelection不是包classification的子类,因而不能调用它的protected类型方法,但是官方文档上train是public类型的

环境:scala2.10.6 spark2.10:1.6.1 jdk1.8

附上相关代码:

import org.apache.spark.ml.classification.DecisionTreeClassifier

object FeatureSelection {
  def selectFeatureGreedyDTNoLimit(){
    val selectfeature=ArrayBuffer[String]()
    val selectsize=selectfeature.size
    val tempfeature=selectfeature++ArrayBuffer(line)

    val vectorDF = new VectorAssembler()
      .setInputCols(tempfeature.toArray)
      .setOutputCol("features")
      .transform(tempdf)
      .select("label", "features")

    val Array(trainRdd, testRdd) =
      vectorDF
      .rdd
      .map(row =>  LabeledPoint(Common.any2Double(row.get(0)).get, row.getAs[Vector](1)))
      .randomSplit(Array(0.5, 0.5), 0L)

    val numClasses = 2
    val categoricalFeaturesInfo = Map[Int, Int]()

    val dt = decisionTreeClassifier.train(trainRdd, categoricalFeaturesInfo, numClasses)
  }
}