0% found this document useful (0 votes)
2 views46 pages

Supervised Learning Basics

The document provides a comprehensive guide to supervised learning, covering its fundamentals, types (regression and classification), mathematical foundations, workflow, and evaluation metrics. It explains key concepts such as hypothesis functions, loss functions, optimization techniques, and challenges like overfitting. The document also includes practical examples and best practices for implementing supervised learning models effectively.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views46 pages

Supervised Learning Basics

The document provides a comprehensive guide to supervised learning, covering its fundamentals, types (regression and classification), mathematical foundations, workflow, and evaluation metrics. It explains key concepts such as hypothesis functions, loss functions, optimization techniques, and challenges like overfitting. The document also includes practical examples and best practices for implementing supervised learning models effectively.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Supervised

Learning
FUNDAMENTALS

Learn supervised learning fundamentals and apply them in practice.


*Disclaimer*
E v e r y o n e l e a r n s u n i q u e l y .

An in-depth guide to Supervised Learning

from fundamental algorithms and intuition to model

evaluation and real-world deployment.

BOSSCODER
ACADEMY
#BeTheBoss 1
TABLE OF Contents
01 Introduction to Supervised Learning
What is Supervised Learning?

4-7

How it Works (Input → Output Mapping)

02 Types of Supervised Learning


• Regression

8-11

• Classification

03 Mathematical & Conceptual Foundations


Hypothesis Function

12-21

Loss Functions (MSE, Cross-Entropy)

Optimization: Gradient Descent

Regularization (L1, L2)

Bias–Variance Tradeoff

04 Supervised Learning Workflow


Data Preparation

22-26

Train–Validation–Test Split

Model Training

Model Evaluation

Hyperparameter Tuning

Deployment Overview

BOSSCODER
ACADEMY #BeTheBoss 2
05 Algorithms in Supervised Learning
Linear Regression

27-32

Logistic Regression

Decision Trees

Random Forests

Support Vector Machines (SVM)

k-Nearest Neighbors (kNN)

Gradient Boosting (XGBoost, LightGBM, CatBoost)

06 Model Evaluation Metrics


• Regression Metrics (MSE, RMSE, MAE, R²)

33-37

• Classification Metrics (Accuracy, Precision, Recall, F1, AUC)

• Confusion Matrix

• Precision–Recall Tradeoff

07 Challenges & Best Practices in Supervised Learning


Overfitting


38-41

Underfitting


Cross-Validation

08 Hands-On Example (High-Level)


End-to-End ML Pipeline for a Classification Problem
42-44

BOSSCODER
ACADEMY #BeTheBoss 3
Phase 1 - Introduction to

Supervised Learning
1.1 What is Supervised Learning?

Input Data Prediction Prediction

It is an
It is an

apple! apple!

Model Model
Annotation
These are
These are

apples apples
?
InputUnsupervised

Data Unsupervised

learning learning

Model Model

Supervised Learning is a machine learning approach in which a model is trained


on a labeled dataset, where each data point consists of an input and its
corresponding correct output. The presence of labeled data provides explicit
guidance to the learning algorithm during training.
Each data point in the dataset consists of:

Input features (X) and

Corresponding output labels (Y).


BOSSCODER
ACADEMY #BeTheBoss 4
The learning objective is to approximate an unknown function


f : X → Y,


which correctly maps inputs to outputs.



During training:



The model predicts an output.

The prediction is compared with the actual label.


The error is calculated using a loss function.

1.2 How it Works (Input → Output Mapping)

The diagram shows how a supervised learning model learns from labeled data and

then makes predictions on new test data.

Working of supervised learning models

Labeled Data

Prediction

Square

Triangle
Model Training

Lables

Test Data

BOSSCODER
ACADEMY
#BeTheBoss 5
Step – 1 Labeled Data (Training Data)

The process starts with labeled data.


This data contains:

- Input data → shapes (square, triangle, hexagon)


- Labels → correct names of those shapes


Each input is already tagged with its correct output.

Step – 2 Labels

Labels represent the correct answers.


In the diagram:

- Square → “Square”


- Triangle → “Triangle”



- Hexagon → “Hexagon”


These labels guide the model and act as a teacher.

Step – 3 Model Training

Both:

- Input data (shapes) and



- Labels are given to the model during training.


BOSSCODER
ACADEMY
#BeTheBoss 6
The model:

- Learns patterns such as edges, angles, and shape structure.


- Compares its predictions with actual labels.


- Reduces errors gradually.

Step – 4 Test Data

After training, new unseen data (test data) is given to the model.


Test data has:

- only input shapes


- No labels shown to the model

Step – 5 Prediction

The trained model analyzes the test shapes.

Based on learned patterns, it predicts:



- Square



- Rectangle

These predictions are the final outputs.

Overall Flow (As per Diagram)

Labeled Data + Labels → Model Training → Trained Model → Test Data →


Prediction (Output)

BOSSCODER
ACADEMY
#BeTheBoss 7
Phase 2 - Types of Supervised

Learning
Supervised learning problems are mainly divided into two types based on the
nature of the output (Y):



Classification: Where the output is a categorical variable (e.g., spam vs. non-
spam emails, yes vs. no).



Regression: Where the output is a continuous variable (e.g., predicting house


prices, stock prices).

Classification Regression

2.1 Classification

Classification is a supervised learning approach where the model learns to assign an


input to one of a predefined set of categories or classes.


From a theoretical perspective, the model learns a decision boundary that separates
different classes in the feature space.
BOSSCODER
ACADEMY #BeTheBoss 8
Nature of Output (Y)

Discrete and finite values


Output represents a class label

Examples:

- Yes / No

- True / False

- Spam / Non-Spam

How Classification Works

The model is trained on labelled data containing known classes.


It identifies patterns and relationships that distinguish one class from another.


For unseen data, the model predicts the most likely class label.

Real-World Examples

Email Filtering: Spam or Non-Spam


Medical Diagnosis: Disease Present or Not


Student Result Prediction: Pass or Fail


Image Classification: Cat, Dog, or Bird

BOSSCODER
ACADEMY #BeTheBoss 9
Key Point

→ The output of classification is a label, not a numeric quantity.

2.2 Regression

Regression is a supervised learning approach where the model predicts a


continuous numerical value based on input features.

From a theoretical standpoint, the goal is to learn a function that approximates the
relationship between inputs and a continuous output.

Nature of Output (Y)

Continuous values within a range


Output represents a numerical quantity


Examples:

→ Price

→ Temperature

→ Marks


How Regression Works (Easy Explanation)

The model observes how input features affect numerical outcomes.


It learns trends and relationships in the data.

BOSSCODER
ACADEMY #BeTheBoss 10
For new inputs, it predicts a value close to the true outcome.

Real-World Examples

House Price Prediction


Stock Price Forecasting


Salary Estimation


Weather Temperature Prediction


Key Point

→ The output of regression is a number, not a category.

BOSSCODER
ACADEMY #BeTheBoss 11
Phase 3 - Mathematical &

Conceptual Foundations
These concepts form the theoretical backbone of supervised learning.

They explain how models represent relationships, measure errors, improve


performance, and generalize to unseen data.

3.1 Hypothesis Function

The hypothesis function represents the assumed mathematical form of the


relationship between the input features (X) and the output variable (Y).

In machine learning, a model does not directly “learn facts.”

Instead, it chooses a hypothesis function and learns the best parameters for it.

What Does the Hypothesis Function Do?

It defines how inputs are transformed into outputs


It represents the model’s structure


Learning means adjusting parameters so predictions match real data

Examples of hypothesis structures:

Linear models → straight-line relationships

BOSSCODER
ACADEMY
#BeTheBoss 12
Discrete and finite values


Output repPolynomial models → curved relationships


Tree-based models → rule-based decisions


Neural networks → layered non-linear transformations

Theory

\hat{y} = h_\theta(X)

Where:

\hat{y} → predicted output


h_\theta → hypothesis function


\theta → learnable parameters (weights, bias)

Example (Linear Regression):



ŷ = wX + b

Why the Hypothesis Function Matters ?

It determines what patterns the model can represent


A simple hypothesis may miss complex patterns (high bias)


A very complex hypothesis may overfit noise (high variance)


In short, the hypothesis function defines the learning capacity of the model.


BOSSCODER
ACADEMY #BeTheBoss 13
3.2 Loss Functions (MSE, Cross-Entropy)

A loss function measures how far the model’s predictions are from the true values.

It converts prediction quality into a single numerical value, which the model tries to
minimize during training.

What Does a Loss Function Do?

Evaluates model performance for each prediction


Provides feedback on how wrong the model is


Guides parameter updates during training


Without a loss function, the model has no direction to improve.


Mean Squared Error (MSE) — Regression

Used when the output is a continuous number

Squares the error between predicted and actual values


Large errors are penalized more heavily

Key properties:

Sensitive to outliers


Smooth and differentiable


Works well for numerical prediction tasks


BOSSCODER
ACADEMY #BeTheBoss 14
Cross-Entropy Loss — Classification

Used when the output is a class label

Measures the difference between:

Predicted probabilities

True class labels


Key properties:

Penalizes confident but wrong predictions


Encourages accurate probability estimation


Works well with logistic regression and neural networks


Why Loss Functions Matter ?

They define what the model should optimize


Different loss functions lead to different learning behavior


Choosing the wrong loss can lead to poor model performance


The loss function defines what “good learning” means for the model.

BOSSCODER
ACADEMY #BeTheBoss 15
3.3 Optimization: Gradient Descent

Gradient Descent is an optimization algorithm used to minimize the loss function


and improve model performance.

It works by iteratively updating model parameters in the direction that reduces


error the most.

How Gradient Descent Works ?

The model starts with random parameter values


It calculates how much the loss changes with respect to each parameter


Parameters are updated step by step to reduce the loss

Theory

θ = θ − η ∇L(θ)

Where:

\theta → model parameters

\eta → learning rate

\nabla L(\theta) → gradient of the loss

BOSSCODER
ACADEMY #BeTheBoss 16
Why It Matters ?

Enables models to learn efficiently from data


Controls speed and stability of learning


Used in almost all ML and deep learning algorithms

3.4 Regularization (L1, L2)

Regularization is a technique used to prevent overfitting by controlling model


complexity.

It works by adding a penalty term to the loss function for large parameter values.

Types of Regularization

1 L1 Regularization (Lasso) : 

Adds absolute value of weights as penalty


Encourages sparsity (some weights become zero)


Useful for feature selection


2 L2 Regularization (Ridge):

Adds squared value of weights as penalty

Shrinks weights smoothly

Improves model stability

BOSSCODER
ACADEMY #BeTheBoss 17
Why It Matters ?

Helps models generalize better to unseen data


Reduces sensitivity to noise


Controls excessive model complexity

3.5 Bias–Variance Tradeoff

The bias–variance tradeoff explains why some models perform well on training
data but fail on new, unseen data.

It describes the balance between a model being too simple and too complex.

A good machine learning model must strike the right balance between bias and
variance to generalize well.

BOSSCODER
ACADEMY #BeTheBoss 18
Bias

Bias refers to the error introduced by making simplifying assumptions about the
data.

Occurs when the model is too simple


Fails to capture important patterns in the data


Leads to underfitting

Characteristics of high bias models:

Poor performance on training data


Poor performance on test data


Oversimplified view of the problem


Example

Using a straight line to model a highly curved relationship.

Variance

Variance refers to the error caused by a model being too sensitive to the training
data.

Occurs when the model is too complex


Learns noise instead of meaningful patterns


Leads to overfitting
BOSSCODER
ACADEMY #BeTheBoss 19
Characteristics of high variance models:

Excellent performance on training data


Poor performance on test data


Highly dependent on the training dataset


Example

A very deep decision tree memorizing every training example.

The Tradeoff

Increasing model complexity:

- Increases variance

- Decreases bias


Decreasing model complexity:


- Increases bias


- Decreases variance


Improving one often worsens the other, which creates the tradeoff.


Why the Bias–Variance Tradeoff Matters ?

Explains why models can fail despite high training accuracy.

BOSSCODER
ACADEMY #BeTheBoss 20
Helps in choosing the right model complexity


Guides the use of regularization, cross-validation, and data size


Forms the foundation for understanding generalization

BOSSCODER
ACADEMY #BeTheBoss 21
Phase 4 - Supervised Learning

Workflow
Supervised learning follows a systematic pipeline designed to ensure that
models learn meaningful patterns, generalize well, and perform reliably in
production.

Feature matrix

Training
Feature vector

Predicting
Step – 1 Data Preparation

Machine learning models assume that data is clean, numerical, and consistent.

In reality, raw data is noisy, incomplete, and unstructured. Data preparation

transforms this raw data into a format that models can effectively learn from.

This step has a direct impact on model accuracy, stability, and convergence.

BOSSCODER
ACADEMY #BeTheBoss 22
What happens:

Handle missing values and incorrect entries


Remove duplicates and outliers


Encode categorical features into numerical form


Scale or normalize numerical features


Select or create meaningful features

Example

In a house price prediction problem, missing prices are handled, locations (text)

are encoded numerically, and house size values are normalized so that no single

feature dominates learning.

Step – 2 Train–Validation–Test Split

To measure how well a model generalizes, it must be evaluated on unseen data.

Splitting the data helps estimate real-world performance and prevents overly

optimistic results caused by testing on training data.

Typical split:

Training set: Used to learn model parameters

Validation set: Used to tune hyperparameters


Test set: Used for final, unbiased evaluation

BOSSCODER
ACADEMY
#BeTheBoss 23
Example

For house price prediction, 70% of the data is used for training, 15% for validation,

and 15% for testing to ensure the model is evaluated on unseen houses.

Step – 3 Model Training

Model training is an optimization process. The model assumes a hypothesis

function and learns parameters that minimize a loss function using an optimizer

such as Gradient Descent.

\text{Minimize } L(y, \hat{y})

What happens:

Initialize model parameters


Generate predictions on training data


Compute loss


Update parameters iteratively


Repeat until convergence

Example

A Linear Regression model learns how features like area, location, and number of

rooms affect house prices by minimizing Mean Squared Error (MSE).

BOSSCODER
ACADEMY
#BeTheBoss 24
Step - 4 Model Evaluation

Evaluation checks how well the trained model performs on data it has never seen.

This step helps identify overfitting, underfitting, and generalization ability.

Common metrics:

Regression: MSE, RMSE, R²


Classification: Accuracy, Precision, Recall, F1-score


Example

The house price model is evaluated on test data using RMSE. A low RMSE
indicates predictions are close to actual prices, while a high RMSE suggests

poor generalization.

Step - 5 Hyperparameter Tuning

Hyperparameters control how a model learns but are not learned directly from
data.

Tuning searches for hyperparameter values that minimize validation error and
improve generalization.

Examples of hyperparameters:

Learning rate


Regularization strength


Tree depth

BOSSCODER
ACADEMY
#BeTheBoss 25
Number of estimators


Example

Different regularization strengths are tested for the house price model, and the
configuration with the lowest validation RMSE is selected.

Step - 6 Deployment Overview

Deployment moves the model from experimentation to real-world usage.

Once deployed, models must handle changing data distributions and be


continuously monitored to maintain performance.

Deployment formats:

REST APIs for real-time predictions


Batch prediction systems


Embedded models in applications


Example

The house price model is deployed as an API where users input house details and
receive a predicted price. Model performance is monitored, and retraining is done
when market trends change.

End-to-End Flow 



Raw Data → Preparation → Split → Train → Evaluate → Tune → Deploy

BOSSCODER
ACADEMY
#BeTheBoss 26
Phase 5 - Algorithms in Supervised

Learning
Supervised learning algorithms learn patterns from labelled data and use those
patterns to make predictions on new inputs.

Each algorithm differs in how it models relationships, handles complexity, and


generalizes to unseen data.

5.1 Linear Regression

Linear Regression is a regression algorithm used to predict continuous numerical


values by fitting a straight line (or plane) through the data.

How it works

Assumes a linear relationship between input features and output


Learns coefficients that minimize prediction error (usually MSE)


Equation (simple form):

y = wX + b

When to use

Relationship is approximately linear


Data is simple and interpretable results are needed

BOSSCODER
ACADEMY
#BeTheBoss 27
Example

Predicting house prices based on size and number of rooms.

5.2 Logistic Regression

Logistic Regression is a classification algorithm used to predict probabilities for

binary or multi-class outcomes.

How it works

Uses a linear combination of features


Applies a sigmoid or softmax function to output probabilities


Converts probabilities into class labels


When to use

Binary or multi-class classification


Need probability-based predictions


Example

Email spam detection (Spam / Not Spam).

5.3 Decision Trees

Decision Trees are rule-based models that split data into branches based on

feature conditions.

BOSSCODER
ACADEMY
#BeTheBoss 28
How it works

Repeatedly splits data to maximize information gain


Forms a tree-like structure of decisions


Final prediction is made at leaf nodes


When to use

Non-linear relationships


Need interpretability and explainability


Example

Loan approval based on income, credit score, and employment status.

5.4 Random Forests

What it is

Random Forest is an ensemble method that combines multiple decision trees to


improve accuracy and reduce overfitting.

How it works

Builds many trees on random subsets of data and features


Aggregates predictions (average or majority vote)


BOSSCODER
ACADEMY
#BeTheBoss 29
Why it works

Reduces variance


More robust than a single tree

Example

Customer churn prediction using multiple behavioral features.

5.5 Support Vector Machines (SVM

SVM is a powerful algorithm that finds the optimal decision boundary that

maximizes the margin between classes.

How it works

Identifies support vectors (critical data points)


Uses kernels to handle non-linear data

When to use

High-dimensional data


Smaller datasets with clear separation


Example

Handwritten digit classification.

BOSSCODER
ACADEMY
#BeTheBoss 30
5.6 k-Nearest Neighbors (kNN)

kNN is a distance-based algorithm that predicts outputs based on the closest


data points.

How it works

Calculates distance (e.g., Euclidean) to neighbors


Predicts based on majority class or average value


When to use

Simple problems


Small datasets


Limitations

Slow for large datasets


Sensitive to feature scaling


Example

Recommending products based on similar users.

5.7 Gradient Boosting (XGBoost, LightGBM, CatBoost)

Gradient Boosting is an ensemble technique that builds models sequentially,


where each new model corrects errors made by previous ones.

BOSSCODER
ACADEMY #BeTheBoss 31
How it works

Trains weak learners (usually trees) one after another


Focuses more on hard-to-predict samples


Popular Implementations

XGBoost: Highly optimized and widely used


LightGBM: Faster and memory-efficient


CatBoost: Handles categorical features well

When to use

Structured/tabular data


High-performance requirements

Example

Fraud detection and ranking systems.

BOSSCODER
ACADEMY
#BeTheBoss 32
Phase 6 - Model Evaluation

Metrics
Model evaluation metrics are designed to estimate how well a learned
hypothesis function generalizes to unseen data.

They provide a measurable approximation of the generalization error, which is


the true objective of supervised learning.

Since the true data-generating distribution is unknown, evaluation metrics act as


empirical proxies for model performance.

6.1 Regression Metrics

In regression, the output variable is continuous.

The objective is to learn a function f(X) that minimizes the expected prediction
error over the data distribution.

A - Mean Squared Error (MSE)

MSE estimates the expected squared loss


It corresponds to maximizing likelihood under a Gaussian noise assumption


Squaring errors makes the metric sensitive to large deviations

BOSSCODER
ACADEMY #BeTheBoss 33
Implication:

Models optimized with MSE focus on reducing large prediction errors


aggressively.

B - Root Mean Squared Error (RMSE)

RMSE is a scale-preserving transformation of MSE


Maintains the same optimization properties


Restores interpretability in the original output units


Implication:


RMSE reflects average deviation while preserving theoretical consistency.

C - Mean Absolute Error (MAE)

MAE corresponds to minimizing absolute deviations


Assumes Laplace-distributed noise instead of Gaussian


Penalizes all errors linearly


Implication:

MAE is theoretically more robust to outliers than MSE.

BOSSCODER
ACADEMY #BeTheBoss 34
D- R² Score (Coefficient of Determination)

Measures the proportion of variance explained by the model


Compares model performance against a baseline (mean prediction)


Indicates explanatory power, not absolute accuracy


Implication:

R² evaluates how well the hypothesis captures the structure of the data.

6.2 Classification Metrics

In classification, the goal is to learn a decision function that minimizes


misclassification risk.

Since different errors have different consequences, multiple metrics are required.

Accuracy

Estimates empirical risk under 0–1 loss


Treats all errors equally


Limitation:

Becomes unreliable under class imbalance


Does not reflect decision confidence


BOSSCODER
ACADEMY
#BeTheBoss 35
Precision and Recall

From a theoretical standpoint, precision and recall decompose classification error


into error types.

Precision: Measures reliability of positive predictions


Recall: Measures completeness of positive detection


Implication:

These metrics allow asymmetric error control depending on task requirements.

F1 Score

Harmonic mean balances precision and recall


Penalizes extreme imbalance between the two


Implication:

F1 approximates optimal performance when both false positives and false


negatives matter.

AUC–ROC

Measures ranking quality independent of thresholds

Estimates probability that a random positive sample is ranked above a


negative one

BOSSCODER
ACADEMY
#BeTheBoss 36
Implication:



AUC evaluates the model’s discriminative power rather than fixed predictions.

6.3 Confusion Matrix

The confusion matrix provides a complete empirical distribution of prediction


outcomes.

From it, all classification metrics can be derived:

Precision


Recall


Specificity


F1 score

6.4 Precision–Recall Tradeoff

Precision–Recall tradeoff arises due to threshold-based decision rules.

Lower threshold → higher recall, lower precision


Higher threshold → higher precision, lower recall


This tradeoff reflects the decision-theoretic nature of classification.

Implication:

Optimal thresholds depend on cost-sensitive loss functions.

BOSSCODER
ACADEMY
#BeTheBoss 37
Phase 7 -Challenges & Best

Practices in Supervised Learning


Building supervised learning models is not just about choosing the right
algorithm.

Models often fail due to poor generalization, which mainly arises from overfitting
or underfitting. Best practices such as cross-validation help mitigate these
issues

7.1 Overfitting

Overfitting occurs when a model learns the training data too well, including noise
and random fluctuations, instead of the true underlying pattern.

The model has low training error but high test error


Typically associated with high variance


Often caused by overly complex models or insufficient data

Symptoms

Excellent performance on training data


Poor performance on unseen data

BOSSCODER
ACADEMY
#BeTheBoss 38
Why it happens

Too many parameters relative to data size

No regularization


Training for too long


Best Practices to Handle Overfitting

Use simpler models


Apply regularization (L1/L2)


Use cross-validation


Increase training data


Early stopping

7.2 Underfitting

Underfitting occurs when a model is too simple to capture important patterns in


the data.

The model has high training error and high test error


Typically associated with high bias


Results from overly restrictive assumptions

BOSSCODER
ACADEMY
#BeTheBoss 39
Symptoms

Poor performance on both training and test data


Model predictions are overly simplistic

Why it happens

Model is too simple


Important features are missing


Excessive regularization


Best Practices to Handle Underfitting

Use more expressive models


Add relevant features


Reduce regularization


Train longer or improve optimization

7.3 Cross-Validation

Cross-validation is a technique used to estimate model performance more


reliably by training and testing the model on multiple data splits.

Provides a better approximation of generalization error

BOSSCODER
ACADEMY
#BeTheBoss 40
Reduces dependency on a single train–test split

How it Works

Data is divided into k subsets (folds)

Model is trained on k–1 folds and tested on the remaining fold


Process is repeated k times


Final performance is averaged

Why it Matters

Detects overfitting early


Improves model selection


Leads to more robust evaluation

BOSSCODER
ACADEMY
#BeTheBoss 41
Phase 8 - Hands-On Example

(High-Level)
End-to-End ML Pipeline for a Classification Problem

This section provides a high-level walkthrough of how a supervised learning


model is built and used in practice, without going into code-level details.

Example Problem: Email Spam Detection

Objective:

Predict whether an incoming email is Spam or Not Spam using supervised


learning.

This is a binary classification problem where the output is a categorical label.

1. Data Collection

A dataset of emails is collected where each email is already labelled as:

Spam

Not Spam


This labelled data forms the foundation of supervised learning.

BOSSCODER
ACADEMY
#BeTheBoss 42
2. Data Preparation

The raw email data is cleaned and transformed so it can be used by a machine
learning model.

At a high level:

Email text is cleaned (removing noise like punctuation)


Text is converted into numerical features


Labels are encoded as binary values


3. Train–Test Split

The dataset is split into:

Training data → used to learn spam patterns


Test data → used to evaluate performance


This ensures the model is tested on emails it has never seen before.

4. Model Training

A classification algorithm (e.g., Logistic Regression or Naive Bayes) is trained on


the training data.

The model learns:

Common patterns in spam emails


Differences between spam and legitimate messages

BOSSCODER
ACADEMY #BeTheBoss 43
5. Model Evaluation

The trained model is evaluated on test data using classification metrics such as:

Precision


Recall


F1-score


This step checks whether the model can correctly identify spam without blocking
important emails.

6. Prediction & Usage

Once validated, the model is used to classify new incoming emails in real time as:

Spam

Not Spam

BOSSCODER
ACADEMY
#BeTheBoss 44
Why Bosscoder?

01 Structured Industry-
vetted Curriculum 02 1:1 Mentorship

Sessions

Our curriculum covers everything you need to get You are assigned a personal mentor currently working in
become a skilled software engineer & get placed. Top product based companies.

03 2200+ Alumni
placement 04 24 LPA AVER AGE
PACKAGE

2200+ Alumni placed at Top Product-based companies. Our Average Placement Package is 24 LPA and
highest is 98 LPA

Niranjan Bagade 10 Years Dheeraj Barik 2 Years

NICE Hike British Petroleum Infosys Hike Amazon


Software Eng. 83% Software Engineer Software Engineer 550% SDE 2
Specialist

EXPLORE M ORE

You might also like