Skip to content

Multiclass Logistic


๐ŸŽฏ Purpose

This QuickRef covers multinomial (multiclass) logistic regression โ€” a generalization of binary logistic used when your target variable has 3 or more unordered classes.


๐Ÿ“ฆ 1. When to Use

Condition Use Multiclass Logistic
Target has โ‰ฅ3 unordered categories โœ… Yes
Categories have no rank or order โœ… Yes
Binary target โŒ Use standard logistic
Ordered categories (low < med < high) โŒ Use ordinal logistic

Examples: Customer segments, product types, political affiliation


๐Ÿงฎ 2. Model Logic (Softmax Function)

$$ P(Y = k \mid X) = \frac{\exp(X \cdot \beta_k)}{\sum_{j=1}^{K} \exp(X \cdot \beta_j)} $$

Each class k has its own coefficient vector ฮฒ_k, compared to a baseline (reference) class.


๐Ÿ› ๏ธ 3. Fitting the Model

from sklearn.linear_model import LogisticRegression
clf = LogisticRegression(multi_class='multinomial', solver='lbfgs')
clf.fit(X_train, y_train)
# statsmodels implementation
import statsmodels.api as sm
model = sm.MNLogit(y, sm.add_constant(X)).fit()

โœ”๏ธ Use predict_proba() for class probabilities


๐Ÿ“Š 4. Output Interpretation

Output Meaning
coef_ Log-odds of class k vs reference
np.exp(coef_) Odds ratio for each class vs baseline
predict_proba() Class probability distribution per row

โš ๏ธ 5. Assumptions

Assumption Notes
Independence of Irrelevant Alternatives (IIA) Assumes relative odds between any two categories do not depend on the presence of others
No ordering Categories must be nominal, not ordinal

โœ… Modeling Checklist

  • [ ] Confirm target is nominal (unordered, โ‰ฅ3 classes)
  • [ ] Model fit using multi_class='multinomial' and proper solver (e.g. lbfgs)
  • [ ] Probabilities interpreted using softmax logic
  • [ ] Log-odds and odds ratios clearly reported
  • [ ] IIA assumption acknowledged or tested (esp. in statsmodels)

๐Ÿ’ก Tip

โ€œBinary logistic picks yes/no. Multiclass logistic asks: which one?โ€