Classification: lesson 4 of 5

Classification

PATH 02MODULE 03LESSON 04 OF 05Next: Class Imbalance Fundamentals

Binary and Multiclass Classification

Distinguish two-class and many-class prediction workflows.

Beginner15 min readmachine-learningclassificationbinarymulticlassmultilabel

Concept

Binary classification chooses between two classes, such as fraud/not fraud or churn/no churn. Multiclass classification chooses one class from several possibilities, such as billing, technical, or account support. Both use the same broad X/y, fit, predict, and generalization workflow.

Binary Classification

Binary tasks often focus on a positive class. A churn model may estimate the probability of churn and apply a threshold to make a churn/no-churn decision. The labels can be strings, booleans, or 0/1; their storage format does not change the category-based task.

Multiclass Classification

For a support ticket, the possible classes might be billing, technical, and account. A multiclass model returns a probability-like value for each class and chooses the most likely class under its decision rule:

billing:   0.10
technical: 0.75
account:   0.15

prediction: technical

The values express the model's relative confidence, not a guarantee that the selected class is correct.

A Compact scikit-learn Example

from sklearn.linear_model import LogisticRegression

X = tickets[["message_length", "prior_tickets"]]
y = tickets["category"]

model = LogisticRegression()
model.fit(X_train, y_train)

labels = model.predict(X_test)
probabilities = model.predict_proba(X_test)

print(model.classes_)

model.classes_ gives the class order used by predict_proba(). For each row, the probability values align with that order. Keep labels readable when possible; replacing meaningful names with numeric codes can make interpretation harder.

Multiclass Is Not Multilabel

Multiclass means one item belongs to one class among several choices. A support ticket classified as exactly one category is multiclass. Multilabel means one item can have several labels at once. A news article tagged technology, AI, and business is multilabel. The difference changes target representation and decision logic, so do not assume every many-category problem is multiclass.

Class Labels and Order

Categories encoded as 0, 1, and 2 do not imply that class 2 is larger or better than class 1. They are names unless the target genuinely has order. An ordered rating may need a different formulation from an unordered product category; start by understanding the business meaning of the label.

Failure Signals

Common Mistakes

  1. Treating a multiclass code as a continuous number.
  2. Forgetting to inspect model.classes_ before reading probabilities.
  3. Confusing multiclass with multilabel.
  4. Assuming the largest probability guarantees a correct label.
  5. Forcing a single label when an item can legitimately have several.

Best Practices

Document allowed classes, label definitions, and whether classes are mutually exclusive. Inspect class frequency and ambiguous examples. Use readable labels in analysis and ensure each probability column is mapped to the correct class.

Interview Perspective

Question: How does multiclass differ from multilabel classification? Answer: multiclass chooses one class from several; multilabel allows several labels for one item. What the interviewer is testing: whether you understand target structure, not just terminology. Follow-up: why inspect model.classes_?

Practice Questions

  1. Is email spam detection binary or multiclass in its simplest form?
  2. Is an article tagged both AI and business multiclass or multilabel?
  3. What does the largest value in a predict_proba() row represent?
  4. Why does numeric encoding not make product categories a regression target?
  5. Name a business task with three mutually exclusive classes.

Quick Quiz

  1. How many labels does a standard multiclass prediction choose? Answer: one.
  2. Can a multilabel item have more than one tag? Answer: yes.
  3. What maps probability columns to labels? Answer: model.classes_.

Key Takeaway

Key Takeaways

Binary classification chooses between two classes; multiclass chooses one of many; multilabel permits several labels. Correct target structure is essential before modeling or interpreting probabilities.

Next Lesson

Next, learn why unequal class frequencies can make simple classification summaries misleading.

Finish this lesson on your terms

Mark it complete when you have worked through the material and are ready to move on.