Logistic Regression

Binary classification, sigmoid, odds ratio

5 free lessons available

Start here

Binary Classification Problem

When a model must predict one of two distinct outcomes – like 'yes' or 'no', 'spam' or 'not spam' – what kind of problem is it solving? This scenario describes a binary classification problem, a fundamental task in machine learning focused on assigning data points to one of two predefined categories.

Binary Classification
A machine learning task where the goal is to predict one of two mutually exclusive and collectively exhaustive categories or classes for a given input.
Example: Determining if an email is 'spam' or 'not spam', predicting if a customer will 'churn' or 'not churn', or identifying if a medical test result is 'positive' or 'negative'.

The two outcomes in binary classification are always distinct and cover all possibilities. This means an instance cannot belong to both categories simultaneously, nor can it belong to neither. These categories are often represented numerically as 0 and 1, or conceptually as True/False, Yes/No, or Positive/Negative. For example, in fraud detection, a transaction is either 'fraudulent' (1) or 'not fraudulent' (0).

Distribution of Outcomes in a Fraud Detection Dataset
This bar chart illustrates a common scenario in binary classification: class imbalance. The majority of transactions are 'Not Fraudulent', while 'Fraudulent' instances are significantly fewer, representing a challenge for model training.
Loading chart...
Key Insight: Binary classification problems often exhibit class imbalance, where one outcome is much rarer than the other, impacting model performance.

Beyond Simple Yes/No: Probabilistic Predictions

While the ultimate goal is a 'yes' or 'no' decision, most binary classifiers do not directly output a hard class label. Instead, they typically provide a probability score that an instance belongs to the positive class. This score is a continuous value between 0 and 1, indicating the model's confidence. For instance, a model might predict a 0.85 probability that an email is spam, rather than just saying 'spam'.

📐 Thresholding Probabilities

To convert a probability score into a definitive class label, a decision threshold is applied. A common threshold is 0.5, meaning:

If P(Positive Class)>0.5⇒Predict Positive Class (1)P(\text{Positive Class}) > 0.5 \Rightarrow \text{Predict Positive Class (1)}
Else ⇒Predict Negative Class (0)\Rightarrow \text{Predict Negative Class (0)}

This threshold can be adjusted based on the specific problem's requirements, such as minimizing false positives or false negatives.

Check Your Understanding
What is the primary output of a binary classifier before a decision threshold is applied?

Binary Classification vs. Other ML Tasks

Comparing Classification and Regression Tasks
Task TypeOutputExample Problem
Binary ClassificationPredicts one of two distinct, mutually exclusive classes.Email spam (spam/not spam), Customer churn (churn/no churn).
Multi-class ClassificationPredicts one of three or more distinct classes.Image recognition (cat/dog/bird), Sentiment analysis (positive/negative/neutral).
RegressionPredicts a continuous numerical value.Predicting house prices ($350,000), Forecasting stock prices ($150.75).
Binary classification is distinct from multi-class classification and regression by its specific output of exactly two categories.

Binary classification problems come with their own set of considerations. Class imbalance, where one class significantly outnumbers the other, is a common challenge that can lead to models biased towards the majority class. Addressing this often requires specialized techniques during data preprocessing or model training. Furthermore, evaluating binary classifiers requires specific metrics like precision, recall, and F1-score, which provide a more nuanced understanding of model performance than simple accuracy, especially with imbalanced datasets.

Key Takeaways
  • Binary classification predicts one of two distinct, mutually exclusive outcomes.

  • Outcomes are often represented as 0/1, True/False, or Yes/No.

  • Models typically output a probability score (0-1) for the positive class, which is then converted to a label using a threshold.

  • Binary classification differs from multi-class classification (more than two outcomes) and regression (continuous numerical output).

  • Challenges like class imbalance and specific evaluation metrics (precision, recall) are central to binary classification problems.

Try it yourself

Logistic Regression Playground

Move a decision boundary and watch log-loss respond. See what the sigmoid turns distance into, and why a confident mistake costs so much.

Open the lab

Open this lesson on its own page →

Ready to keep this from fading?

Bitelrn turns lessons like this into a full course — quizzes, a knowledge map, and spaced review.

Get started free