使用sklearn和logisticRegress的多项式logit中的结果变量指定参考类别

发布于 2025-01-24 20:44:17 字数 135 浏览 0 评论 0 原文

我正在尝试使用Sklearn的LogisticRecression模块拟合多项式logit模型。

我的结果(y)有4个级别。我需要将这些级别之一指定为参考类别(或基线)。 LogisticRegress模块​​是否提供了指定此参考类别的方法?

I am trying to fit a multinomial logit model using LogisticRegression module from Sklearn.

My outcome (y) has 4 levels. I need to specify one of these levels as the reference category (or baseline). Does the LogisticRegression module provides a way of specifying this reference category?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羅雙樹 2025-01-31 20:44:17

Sklearn中多个类的LogisticRecression使用一个VS ALL或ALL或SOFTMAX参数化,具体取决于您是否指定了多项式。无论哪种情况,它都不使用参考来计算解决方案,而是计算每个输出类的系数向量。如果您使用多项式规范,则可以选择与您要设置的参考类别相对应的系数,并从其他方面减去该类别,该系数应将等效的解决方案恢复到您似乎想要的一个。

有关如何指定多项式:

LogisticRegression for multiple classes in sklearn uses either one vs all or a softmax parameterization of the problem, depending on whether you specify multinomial. In either case it does not compute the solution using a reference, but instead computes a vector of coefficients for each output class. If you use the multinomial specification you can select the coefficients corresponding to the reference category you would like to set and subtract that from the others, which should recover an equivalent solution to the one you seem to want.

See the docs for how to specify multinomial: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文