您是对的,这是一个版本控制问题。这个
github code example
您给出的是Spark当前的主分支,其中API的这一部分有一些重大更改。
您一直在关注Spark 2.3中的代码。然而,目前这个版本还不稳定,无法下载。这就是
version 2.2 branch
相同代码的示例如下所示:
val training = spark
.read
.format("libsvm")
.load("data/mllib/sample_multiclass_classification_data.txt")
val lr = new LogisticRegression()
.setMaxIter(10)
.setRegParam(0.3)
.setElasticNetParam(0.8)
// Fit the model
val lrModel = lr.fit(training)
// Print the coefficients and intercept for multinomial logistic regression
println(s"Coefficients: \n${lrModel.coefficientMatrix}")
println(s"Intercepts: ${lrModel.interceptVector}")
// $example off$
spark.stop()
换句话说,您尝试使用的方法尚未在Spark版本中实现。