# 多项逻辑回归

**多项逻辑回归**（Multinomial logistic regression）是一种针对具有两个以上无序类别的分类结果的回归模型，它通过建模每个类别相对于选定基线的概率，对二项逻辑回归进行了扩展。它也被称为多类逻辑回归、softmax回归、多分逻辑回归、多项logit、最大熵（MaxEnt）分类器以及条件最大熵模型。<sup>[1](https://www3.stat.sinica.edu.tw/ss_newpaper/SS-2021-0082_na.pdf)</sup><sup> • </sup><sup>[2](https://unire.unige.it/bitstream/handle/123456789/15510/tesi37226902.pdf?group=an&isAllowed=y&sequence=1)</sup>

| 关键事实 | 详情 |
|---|---|
| 用途 | 将具有三个或更多类别的名义响应建模为预测变量的函数，推广了两类别逻辑模型<sup>[3](https://online.stat.psu.edu/stat504/Lesson08)</sup> |
| 核心方程 | 以基线类别 \( j^* \) 为参照，对每个非基线类别 \( j \)，\( \log(\pi_{ij}/\pi_{ij^*}) = x_i^T \beta_j \)<sup>[3](https://online.stat.psu.edu/stat504/Lesson08)</sup> |
| 系数含义 | \( \beta_j \) 的第 \( k \) 个元素表示在其他项保持不变的情况下，第 \( k \) 个预测变量每增加一个单位时，类别 \( j \) 相对于基线的对数几率的变化<sup>[3](https://online.stat.psu.edu/stat504/Lesson08)</sup> |
| 机器学习形式 | softmax函数取代逻辑函数，将 \( K \) 个线性得分映射到概率单纯形上的概率<sup>[4](https://inst.eecs.berkeley.edu/~cs188/textbook/ml/multi-class-logistic.html)</sup><sup> • </sup><sup>[5](https://www.renyi.hu/~zsamboki/teaching/dml-summer-2026/lecture_notes/0617_logistic_regression/)</sup> |
| 估计 | 参数通常通过极大似然联合估计<sup>[1](https://www3.stat.sinica.edu.tw/ss_newpaper/SS-2021-0082_na.pdf)</sup> |
| 已知缺陷 | 分离和稀疏数据病态会产生无穷或不稳定的估计；惩罚似然方法可以解决这些问题<sup>[6](https://academic.oup.com/aje/article/187/4/864/4084405?guestAccessKey=27489e1b-0bd2-4799-915a-ce16c9049ea9)</sup> |

## 基线类别logit模型

该模型将二项逻辑模型推广至具有两个以上类别的响应。以 \( j^* \) 为基线类别，模型为

\[ \log\left(\dfrac{\pi_{ij}}{\pi_{ij^*}}\right)=x_i^T \beta_j,\qquad j \neq j^* \]

其中 \( x_i \) 长度为 \( p \)，是预测项及所关注的任何交互作用的向量，截距可通过将 \( x_{i1}=1 \) 视为一个预测变量来纳入。每个非基线类别对应一个系数向量 \( \beta_j=(\beta_{1j},\beta_{2j},\ldots,\beta_{pj})^T \)。分析者可以自行选择基线，也可以让软件自动选择。<sup>[3](https://online.stat.psu.edu/stat504/Lesson08)</sup>

由于 \( K \) 个类别的概率之和必须为1，这些logit方程中只有 \( K-1 \) 个是自由的，一旦固定基线，模型便完全确定。不同基线选择对同一模型的重新拟合效果相同，得到相同的似然和相同的拟合值；改变的只是参数化方式。<sup>[3](https://online.stat.psu.edu/stat504/Lesson08)</sup>

**解释。** 每个系数应理解为对两个类别之间比较的效应，而非对单个类别的效应。正系数增大落入类别 \( j \) 而非基线的几率；优势比 \( e^{\beta_{kj}} \) 给出预测变量每增加一个单位时这些几率的乘性变化。<sup>[3](https://online.stat.psu.edu/stat504/Lesson08)</sup>

## softmax形式

在机器学习中，同一模型用softmax函数来书写。为了将数据点分为 \( K \) 个不同类别，softmax取代逻辑函数，建模特征为 \( \mathbf{x} \) 的点具有标签 \( i \) 的概率。<sup>[4](https://inst.eecs.berkeley.edu/~cs188/textbook/ml/multi-class-logistic.html)</sup> 该模型是复合映射 \( \mathbf{R}^d \xrightarrow{f_\theta} \mathbf{R}^c \xrightarrow{\mathrm{softmax}} \Delta^{c-1} \)，其中参数为 \( \theta=(W,\mathbf{b}) \) 的 \( f_\theta \) 为每个类别产生一个线性得分，softmax将得分向量映射到概率单纯形上，即非负且和为1的向量集合。<sup>[5](https://www.renyi.hu/~zsamboki/teaching/dml-summer-2026/lecture_notes/0617_logistic_regression/)</sup>

两种表述是等价的。在两类别情形下，softmax输出恰好具有S形函数的形式，其自变量等于两个类别得分之差 \( z_1 - z_2 \)；只有这个差值起作用，这正是二项模型仅依赖一个线性得分的原因。<sup>[7](https://pages.cogsci.uos.de/rrawiel/introdeeplearning/script/classification.html)</sup> 结果被建模为 \( K \) 个类别概率 \( p_1,\ldots,p_K \) 上的分类分布，满足 \( \sum_{k=1}^K p_k=1 \) 且 \( p_k \in [0,1] \)，拟合过程最大化观测标签的似然。<sup>[8](https://dats.columbian.gwu.edu/courses/data-mining/week-9/multinomial.html)</sup><sup> • </sup><sup>[1](https://www3.stat.sinica.edu.tw/ss_newpaper/SS-2021-0082_na.pdf)</sup>

## 起源与选择行为

多项logit形式在离散选择理论中具有公理化基础。丹尼尔·麦克法登（Daniel McFadden）于1974年引入了条件logit模型，明确地将选项属性与选择概率联系起来，而无需借助未知的效用函数。一项刻画结果表明，如果选择概率满足正性和无关备选项独立性（IIA），则存在效用函数 \( v \)，使得选择概率取多项logit形式。<sup>[9](https://link.springer.com/article/10.1007/s00199-020-01281-1)</sup> 教科书中的论述同样将广义logit模型追溯至麦克法登1973年在此背景下的工作。<sup>[10](https://citeseerx.ist.psu.edu/document?doi=1bd69b2ad324f9799e889fdec28a604f68cb4938&repid=rep1&type=pdf)</sup>

## 实际拟合

软件实现在处理多类别情形时各有不同。在scikit-learn的`LogisticRegression`中，对于 \( n_{\text{classes}} \ge 3 \) 的多类别问题，除`liblinear`外的所有求解器都优化带惩罚的多项损失；`liblinear`仅处理二分类，但可通过`OneVsRestClassifier`扩展到多类别。`lbfgs`、`newton-cg`、`newton-cholesky`和`sag`求解器仅支持L2正则化或无正则化，而只有`saga`求解器支持弹性网络，即L1和L2惩罚的组合。默认求解器在0.22版本中从`liblinear`改为`lbfgs`，`newton-cholesky`的多项支持在1.6版本中引入。<sup>[11](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html)</sup> 默认应用正则化，\( C=1.0 \)。<sup>[11](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html)</sup>

较早的scikit-learn用户指南指出了两种多类别策略之间的实际区别：真正的多项模型应给出校准更好的概率估计，而一对多设置不会学到稀疏模型。<sup>[12](https://scikit-learn.org/0.16/_downloads/scikit-learn-docs.pdf)</sup>

## 稀疏数据与分离

多项逻辑回归与其他离散结果模型共有相同的病态问题。分离——即某个预测变量或预测变量的组合完美地预测结果——以及相关的稀疏数据问题会产生无穷的极大似然估计。导致分离的典型建模策略包括将连续变量分类化以及对名义变量使用许多类别。惩罚方法通过收缩估计来消除此类病态，适用于多项回归以及概率单位回归、比例风险回归和条件逻辑回归。<sup>[6](https://academic.oup.com/aje/article/187/4/864/4084405?guestAccessKey=27489e1b-0bd2-4799-915a-ce16c9049ea9)</sup> 对于稀疏多项数据中的置信区间，当有限样本偏差和数据分离可能出现时，基于惩罚似然的剖面似然区间优于极大似然方法。<sup>[13](https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.2518)</sup>

## 有序结果与模型选择

当响应类别具有自然顺序时，分析者必须在忽略顺序的多项模型与利用顺序的累积logit（比例优势）模型之间做出选择。一项关于离散有序结果风险预测的模拟与数据研究发现，当真实模型为多项逻辑回归时，比例优势模型往往产生较差的风险估计，即使在大型开发数据集上校准斜率也显著偏离1。尽管样本量要求更大，作者总体上推荐使用多项逻辑回归进行离散有序结果的风险预测建模。<sup>[14](https://arxiv.org/abs/2104.09282)</sup> 相邻类别logit在同一多分模型族内提供了另一种名义尺度替代方案。<sup>[3](https://online.stat.psu.edu/stat504/Lesson08)</sup>

## References

1. [Statistica Sinica: newly accepted paper on multinomial logistic regression](https://www3.stat.sinica.edu.tw/ss_newpaper/SS-2021-0082_na.pdf)
2. [Multinomial Logistic Regression (thesis chapter), Università di Genova](https://unire.unige.it/bitstream/handle/123456789/15510/tesi37226902.pdf?group=an&isAllowed=y&sequence=1)
3. [Lesson 8: Multinomial Logistic Regression Models, STAT 504, Penn State Eberly College of Science](https://online.stat.psu.edu/stat504/Lesson08)
4. [Multi-Class Logistic Regression, CS 188 Introduction to Artificial Intelligence, UC Berkeley](https://inst.eecs.berkeley.edu/~cs188/textbook/ml/multi-class-logistic.html)
5. [Multinomial Logistic Regression I, Introduction to Deep Learning lecture notes, Rényi Institute](https://www.renyi.hu/~zsamboki/teaching/dml-summer-2026/lecture_notes/0617_logistic_regression/)
6. [Separation in Logistic Regression: Causes, Consequences, and Control, American Journal of Epidemiology](https://academic.oup.com/aje/article/187/4/864/4084405?guestAccessKey=27489e1b-0bd2-4799-915a-ce16c9049ea9)
7. [Classification, Introduction to Deep Learning course script, University of Osnabrück](https://pages.cogsci.uos.de/rrawiel/introdeeplearning/script/classification.html)
8. [Multinomial Logistic Regression, Introduction to Data Mining, George Washington University](https://dats.columbian.gwu.edu/courses/data-mining/week-9/multinomial.html)
9. [An axiomatic foundation of conditional logit, Economic Theory, Springer](https://link.springer.com/article/10.1007/s00199-020-01281-1)
10. [Multinomial Logit Models, CiteSeerX](https://citeseerx.ist.psu.edu/document?doi=1bd69b2ad324f9799e889fdec28a604f68cb4938&repid=rep1&type=pdf)
11. [sklearn.linear_model.LogisticRegression, scikit-learn 1.9.1 documentation](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html)
12. [scikit-learn 0.16 user guide](https://scikit-learn.org/0.16/_downloads/scikit-learn-docs.pdf)
13. [Confidence intervals for multinomial logistic regression in sparse data, Statistics in Medicine](https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.2518)
14. [Risk prediction models for discrete ordinal outcomes: calibration and the impact of the proportional odds assumption, arXiv](https://arxiv.org/abs/2104.09282)
15. [Multiclass classification by sparse multinomial logistic regression, arXiv](https://arxiv.org/abs/2003.01951)
16. [Extreme Sparse Multinomial Logistic Regression for Hyperspectral Image Classification, arXiv](https://arxiv.org/abs/1709.02517)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing › Regression analysis

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/multinomial-logistic-regression

English original: https://www.edgepedia.org/multinomial-logistic-regression
