Sitemap
3 min readNov 23, 2025

--

Supervised Learning

Supervised Learning is one type of machine learning techniques where the target is known.

It is classified into two types:

1. Classification

2. Regression

Regression — Regression finds a relationship between input and output and predicts a numeric value

eg. Predict House Price

Classification — learns patterns to decide which class the new data belongs to.

eg. Email Filtering — spam or not

Logistic Regression:

Logistic Regression is a popular machine learning algorithm used for classification problems — especially when the output has two classes (like Yes/No, 0/1, Spam/Not Spam).

Even though the name says “regression”, logistic regression is not used for predicting numbers.

It is used to predict probabilities and classify data into categories.

Example

You want to predict whether a student will pass or fail based on study hours.

Logistic regression learns from data and outputs a probability, like:

Probability of passing = 0.85 (85%) → model predicts Pass

Probability of passing = 0.30 (30%) → model predicts Fail

How it works (simple steps)

It finds a relationship between the input (study hours) and output (pass/fail)

It uses a sigmoid function to convert the result into a probability between 0 and 1

If probability ≥ 0.5 → classify as 1 (Yes/Pass)

If probability < 0.5 → classify as 0 (No/Fail)

Sigmoid Function (Formula)

Probability = 1 / (1 + e^(-x))

It makes a smooth curve between 0 and 1, like an S-shape.

Get Pavithra M’s stories in your inbox

Join Medium for free to get updates from this writer.

Metrics in classification

In classification problems, we evaluate how well the model predicts categories using classification metrics. These metrics tell us how accurate and reliable the model is.

  1. Confusion Matrix

Here,

When we predict the Actual Yes as True, then it’s True Positive (TP)

When we predict the Actual Yes as False, then it’s False Negative (FN)

When we predict the Actual No as True, then it’s False Positive (FP)

When we predict the Actual No as False, then it’s True Negative (TN)

We can derive the classification metrics based on the confusion matrix as below

2. Accuracy

Measures how many predictions were correct out of total predictions.

Accuracy = (TP + TN)/(TP+TN+FP+FN)

3. Recall or Sensitivity

Based on the actual data of all the positive values, how many recalled correctly

Recall = TP/ (TP + FN)

4. Precision

Out of all samples that the model predicted as Positive, how many were actually Positive?

Precision = TP/(TP+FP)

How to decide if the model is good based on Recall and Precision?

When we want high True Positive rate where we cannot afford to lose any True Positive then we choose Recall as evaluation metrics, likewise if we want high True Negative Rate, then Specificity helps and in other case we can opt for precision as evaluation metrics.

Example Case

Email Spam Classification

Means: Many non-spam emails are wrongly predicted as spam → Not a good model

Medical test (cancer detection)

Mean: Poor model even though accuracy is high.

--

--