gpt4 book ai didi

apache-spark-ml - 如何从 Spark ML Logistic 回归模型中获取模型摘要?

转载 作者:行者123 更新时间:2023-12-03 21:15:56 27 4
gpt4 key购买 nike

我正在关注一个来自 - https://spark.apache.org/docs/2.3.0/ml-classification-regression.html#multinomial-logistic-regression 的例子

当我尝试获取模型摘要时,我遇到了错误。这是我的错误代码 -

// START 

import org.apache.spark.ml.classification.LogisticRegression

// Load training data
val training = spark.read.format("libsvm").load("file:///Users/my_username/Desktop/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: \n${lrModel.interceptVector}")

val trainingSummary = lrModel.summary
org.apache.spark.SparkException: No training summary available for this LogisticRegressionModel
at org.apache.spark.ml.classification.LogisticRegressionModel$$anonfun$summary$1.apply(LogisticRegression.scala:1002)
at org.apache.spark.ml.classification.LogisticRegressionModel$$anonfun$summary$1.apply(LogisticRegression.scala:1002)
at scala.Option.getOrElse(Option.scala:121)
at org.apache.spark.ml.classification.LogisticRegressionModel.summary(LogisticRegression.scala:1001)
... 48 elided

我想在这一步之后打印模型中的指标。

我已经从- https://github.com/apache/spark/blob/master/data/mllib/sample_multiclass_classification_data.txt获得了数据

最佳答案

我的不好,我使用的是 Spark 2.2.0 版,文档说要使用 2.3.0

它适用于 2.3.0

关于apache-spark-ml - 如何从 Spark ML Logistic 回归模型中获取模型摘要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53947662/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com