Lesson Plan: Data Preparation &
Preprocessing using NumPy
Binarization, Mean Removal, Scaling, Normalization
Subject: Machine Learning / Data Science
Topic: Data Preprocessing Techniques using NumPy (Unit Topic 4)
Cognitive Level: Applying (Bloom's Taxonomy Level 3)
Duration: 2 sessions × 50 minutes (lecture + hands-on lab)
Class: Diploma — Computer Engineering
1. Learning Objectives
By the end of this lesson, students will be able to (at the Apply level):
Apply NumPy functions to prepare and preprocess raw data.
Apply the Binarization technique to convert numerical data into binary
values.
Apply Mean Removal to center data around zero.
Apply Scaling to bring data within a defined range.
Apply Normalization to adjust data to a common scale/unit norm.
Write and execute Python/NumPy code to implement each technique
on a sample dataset.
2. Prerequisite Knowledge
Basics of Python programming
Basics of NumPy arrays (creation, indexing, basic operations)
Concept of why raw data needs preprocessing before feeding to ML
algorithms
3. Teaching Aids
Python IDE / Jupyter Notebook for live coding
Projector for demonstrating code execution
Sample dataset (small NumPy array of raw numeric values, e.g., exam
scores or sensor readings)
Printed/shared code snippets for student lab practice
4. Lesson Delivery — Session 1: Concepts +
Demonstration (50 min)
Time Activity Content
0–5 Quick recall: Why is data preprocessing
Recap
min necessary before applying ML algorithms?
Introduce the four techniques: Binarization,
5–12
Overview Mean Removal, Scaling, Normalization — when
min
and why each is used
Explain concept: converting values
above/below a threshold into 0s and 1s. Live
12–
demo using
22 Binarization
[Link] or
min
NumPy conditional operations on a sample
array
22– Explain concept: removing the mean so data is
Mean
32 centered around zero (removes bias). Live
Removal
min demo using data - [Link](axis=0)
Explain concept: bringing feature values into a
32– defined range (e.g., 0 to 1). Live demo using
42 Scaling Min-Max scaling formula with NumPy: (data
min - [Link]()) / ([Link]() -
[Link]())
Time Activity Content
42– Explain concept: adjusting values so each
50 Normalization row/vector has unit norm (L1/L2). Live demo
min using NumPy: dividing each row by its norm
5. Lesson Delivery — Session 2: Hands-on Lab (50
min)
Time Activity Content
0–5 Quick recap of all four techniques and their
Recap
min formulas
Students work individually/in pairs on a lab sheet:
given a raw NumPy array (e.g., 2D array of student
5–40 Lab
marks or sensor data), apply all four preprocessing
min Practice
techniques step-by-step and print results after
each step
40–
Peer Students compare outputs with a neighbor and
47
Review discuss differences observed after each technique
min
47–
50 Wrap-up Recap and preview of next topic
min
6. Sample Code Walkthrough
import numpy as np
from sklearn import preprocessing
# Sample raw data
data = [Link]([[3, -1.5, 2, -5.4],
[0, 4, -0.3, 2.1],
[1, 3.3, -1.9, -4.3]])
# 1. Binarization
binarized =
[Link](threshold=1.4).transform(data)
print("Binarized data:\n", binarized)
# 2. Mean Removal
mean_removed = data - [Link](axis=0)
print("Mean removed data:\n", mean_removed)
print("New mean:", mean_removed.mean(axis=0))
# 3. Scaling (Min-Max)
data_scaler = [Link](feature_range=(0,
1))
scaled_data = data_scaler.fit_transform(data)
print("Scaled data:\n", scaled_data)
# 4. Normalization (L1 norm)
normalized_data = [Link](data, norm='l1')
print("Normalized data:\n", normalized_data)
7. Comparison Chart (for board/slide)
Technique Purpose Key Idea NumPy/Sklearn Approach
Values
Convert
above
to
Binarization threshold Binarizer(threshold=x)
binary
→ 1, else
values
→0
Subtract
Remove
mean
Mean bias,
from data - [Link](axis=0)
Removal center
each
data
feature
Scaling Bring Min-Max MinMaxScaler(feature_range=
values formula (0,1))
Technique Purpose Key Idea NumPy/Sklearn Approach
into a
fixed
range
Scale
each Divide by
[Link](data,
Normalization row to L1/L2
norm='l1')
unit norm
norm
8. Assessment / Lab Exercise (Applying Level)
1. Given a raw NumPy array of your own (at least 4×3), apply Binarization
with a threshold of your choice and print the result.
2. Apply Mean Removal on the same array and verify the new mean is
approximately zero.
3. Apply Min-Max Scaling to bring all values into the range [0, 1].
4. Apply L2 Normalization on the array and verify each row has unit norm.
5. Write a short observation (2–3 lines) comparing how the dataset looks
after each technique.
9. Summary
Data preprocessing prepares raw data for effective use in ML
algorithms.
Binarization converts numeric data into binary form using a threshold.
Mean Removal centers data around zero to eliminate bias.
Scaling adjusts data to fit within a specific range.
Normalization rescales data so each data point has a unit norm.
NumPy (along with [Link] ) provides simple,
efficient functions to apply all these techniques.
10. Suggested Homework/Activity
Take any small dataset (can be self-created, e.g., 5 students' marks in
3 subjects) and apply all four preprocessing techniques using NumPy.
Submit the code along with before/after output for each step.