解释多项式逻辑回归的系数矩阵、截距向量和混淆矩阵
Interpreting coefficientMatrix, interceptVector and Confusion matrix on multinomial logistic regression
任何人都可以解释如何解释 coefficientMatrix
、interceptVector
、Confusion matrix
一个 multinomial logistic regression
。
根据 Spark 文档:
Multiclass classification is supported via multinomial logistic (softmax) regression. In multinomial logistic regression, the algorithm produces K sets of coefficients, or a matrix of dimension K×J where K is the number of outcome classes and J is the number of features. If the algorithm is fit with an intercept term then a length K vector of intercepts is available.
我使用 spark ml 2.3.0 转了一个例子,得到了这个结果。
.
如果我分析我得到的结果:
coefficientMatrix
的维度为 5 * 11
interceptVector
的维度为 5
如果是,为什么 the Confusion matrix
的维度是 4 * 4
?
另外,谁能解释一下coefficientMatrix
,interceptVector
?
为什么我得到负系数?
如果分类后类的个数是5,为什么我在the confusion matrix
中得到4行?
编辑
我忘了说我还是机器学习的初学者,我在 google 中的搜索没有帮助,所以也许我会投赞成票 :)
关于 4x4 混淆矩阵:我想当你将你的数据分成测试和训练时,你的训练集中有 5 classes 而你的只有 4 classes测试集。如果响应变量的分布不平衡,这很容易发生。
在建模之前,您需要尝试在测试和训练之间执行一些分层拆分。如果您使用的是 pyspark,您可能会发现这个库很有用:https://github.com/databricks/spark-sklearn
现在关于多 class 逻辑回归的负系数:正如您提到的,您返回的系数矩阵形状是 5x11。
Spark 通过一对多的方法生成了五个模型。第一个模型对应于正 class 是第一个标签而负 class 由所有其他标签组成的模型。可以说这个模型的第一个系数是-2.23。为了解释这个系数,我们采用 -2.23 的指数,即(大约)0.10。此处解读:'With one unit increase of 1st feature we expect a reduced odds of the positive label by 90%'
任何人都可以解释如何解释 coefficientMatrix
、interceptVector
、Confusion matrix
一个 multinomial logistic regression
。
根据 Spark 文档:
Multiclass classification is supported via multinomial logistic (softmax) regression. In multinomial logistic regression, the algorithm produces K sets of coefficients, or a matrix of dimension K×J where K is the number of outcome classes and J is the number of features. If the algorithm is fit with an intercept term then a length K vector of intercepts is available.
我使用 spark ml 2.3.0 转了一个例子,得到了这个结果。
如果我分析我得到的结果:
coefficientMatrix
的维度为 5 * 11
interceptVector
的维度为 5
如果是,为什么 the Confusion matrix
的维度是 4 * 4
?
另外,谁能解释一下coefficientMatrix
,interceptVector
?
为什么我得到负系数?
如果分类后类的个数是5,为什么我在the confusion matrix
中得到4行?
编辑
我忘了说我还是机器学习的初学者,我在 google 中的搜索没有帮助,所以也许我会投赞成票 :)
关于 4x4 混淆矩阵:我想当你将你的数据分成测试和训练时,你的训练集中有 5 classes 而你的只有 4 classes测试集。如果响应变量的分布不平衡,这很容易发生。
在建模之前,您需要尝试在测试和训练之间执行一些分层拆分。如果您使用的是 pyspark,您可能会发现这个库很有用:https://github.com/databricks/spark-sklearn
现在关于多 class 逻辑回归的负系数:正如您提到的,您返回的系数矩阵形状是 5x11。 Spark 通过一对多的方法生成了五个模型。第一个模型对应于正 class 是第一个标签而负 class 由所有其他标签组成的模型。可以说这个模型的第一个系数是-2.23。为了解释这个系数,我们采用 -2.23 的指数,即(大约)0.10。此处解读:'With one unit increase of 1st feature we expect a reduced odds of the positive label by 90%'