MACHINE LEARNING
UNIT 1
Introduction to Data Preprocessing & Machine Learning
Complete Theory + 100% Lab Assessment Concepts
Lab 1: Exploratory Data Analysis (EDA) • Lab 2: Normalization (Min-Max & Z-Score)
Covers: Data objects & attribute types, similarity / distance measures, data
preprocessing, normalization, the machine-learning process & types — plus full
concept explanations, pseudocode, annotated code, worked calculations and viva
Q&A for both Unit-1 lab exercises.
I MSc Artificial Intelligence & Machine Learning · CIA Exam Preparation
Machine Learning · Unit 1 — Exam Preparation Page 1
Contents
PART 1 — Data Fundamentals: Objects, Attributes & Types
PART 2 — Similarity, Dissimilarity & Distance Measures
PART 3 — Introduction to Machine Learning
PART 4 — Data Preprocessing & Normalization (in depth)
PART 5 — LAB 1: Exploratory Data Analysis (full concept + code + viva)
PART 6 — LAB 2: Normalization (full concept + code + worked sums + viva)
PART 7 — Rapid Revision & Formula Sheet
How to use this in the exam: Parts 5 & 6 are the practical core (the labs). Parts 1–4 are the
theory those labs are built on. The boxed Viva tables and the Worked Calculations in Part 6 are
the highest-yield revision.
Machine Learning · Unit 1 — Exam Preparation Page 2
PART 1 Data Fundamentals: Objects, Attributes &
Types
1.1 Data Objects and Attributes
A dataset is a collection of data objects. A data object represents one real-world entity — also
called a sample, instance, record, tuple, or data point. Each data object is described by
attributes (also called features, variables, or dimensions).
• In a table, rows = data objects and columns = attributes.
• Airways example: each flight is a data object; Airline, Distance, Price, Delay are its attributes.
• Other examples: a sales DB stores customers; a medical DB stores patients; a university DB
stores students.
1.2 Attribute Types
Knowing an attribute's type decides how you clean, encode and scale it — so this is foundational
for both lab exercises.
Type Meaning Example (Airways)
Airline, Source city, Aircraft
Nominal Categories / names, no order
type
Only 2 states (0/1). Symmetric = both equally
Binary important (gender); Asymmetric = one state matters Is_Delayed? (0/1)
more (test +/−)
Class: Economy < Business;
Ordinal Ordered, but gaps not meaningful
Stops: low/med/high
Temperature (°C), calendar
Numeric – Interval Ordered, equal units, no true zero
dates
Price, Distance, Duration,
Numeric – Ratio Has a true zero, ratios make sense
Passenger count
Discrete vs Continuous
• Discrete — finite / countable values (number of stops, zip codes). Often stored as integers.
• Continuous — real-valued, measured (price, duration, distance). Stored as floats. Binary is a
special case of discrete.
1.3 Types of Datasets
Category Examples
Relational records, data matrix (numeric), document data (text),
Record
transaction data
Graph & Network World Wide Web, social/information networks, molecular structures
Time-series (temporal), sequential data, genetic sequences, video
Ordered
(sequence of images)
Spatial / Image / Multimedia Maps & spatial data, images, video
1.4 Types of Data (by structure & usage)
Machine Learning · Unit 1 — Exam Preparation Page 3
By structure Description & examples
Structured Fixed fields & schema — SQL tables, spreadsheets, transaction logs
Semi-structured Self-describing, flexible schema — JSON, XML, NoSQL (MongoDB), server logs
Unstructured No predefined structure — social posts, emails, images, audio/video
By temperature/usage: Hot data = frequently accessed, low-latency (live flight tracking);
Cold data = rarely accessed, archived (old compliance records); Viral data = sudden spike in
popularity.
Machine Learning · Unit 1 — Exam Preparation Page 4
PART 2 Similarity, Dissimilarity & Distance
Measures
2.1 Proximity
Proximity is a numerical value for the closeness between two objects.
• Similarity → value close to 1 (objects are alike).
• Dissimilarity → value close to 0 (objects are alike) / large (objects differ).
• By definition, proximity measures usually lie in the range [0, 1].
2.2 Distance Measure vs Distance Metric
A distance measure is any method that quantifies dissimilarity between two objects. A
distance metric is a stricter distance measure that satisfies four properties:
Property Condition
Non-negativity d(x, y) ≥ 0
Identity d(x, y) = 0 ⟺ x = y
Symmetry d(x, y) = d(y, x)
Triangle inequality d(x, z) ≤ d(x, y) + d(y, z)
Key insight (very common viva line): Every distance metric is a distance measure, but not
every distance measure is a metric.
2.3 Euclidean Distance
The Euclidean distance is the straight-line (shortest) distance between two points — "as a bird
flies". It is derived from the Pythagorean theorem and is the default distance in KNN, K-Means
and clustering.
Formulas
2-D: d = √[ (x₂ − x₁)² + (y₂ − y₁)² ]
3-D: d = √[ (x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)² ]
n-D: d = √[ Σ (x₂ᵢ − x₁ᵢ)² ] for i = 1 … n
Worked example
Distance from point (2, 3) to (5, 7):
d = √(3² + 4²) = √(9 + 16) = √25 = 5
• Applications: clustering & classification, nearest-neighbour search, feature-space mapping.
• Why scaling matters here: Euclidean distance is dominated by large-magnitude features —
the reason normalization (Part 4 & Lab 2) is essential before using it.
2.4 Cosine Similarity
Cosine similarity measures the orientation (angle) between two vectors, not their
magnitude. It is the standard measure for text / NLP (document similarity).
cos(θ) = (A · B) / (‖A‖ · ‖B‖)
Machine Learning · Unit 1 — Exam Preparation Page 5
Angle θ Score Meaning
0° (collinear) 1.0 Identical direction — most similar
45° ≈ 0.71 Partially similar
90° (orthogonal) 0.0 Unrelated direction
Here A · B is the dot product and ‖A‖ is the vector magnitude (√(a₁² + a₂² + … + aₙ²)). Used in
search, document clustering, plagiarism detection and recommendation systems.
2.5 Family of Similarity Measures (overview)
The broader family includes the L / Minkowski group (Euclidean, Manhattan, Chebyshev),
p
inner-product group (dot product, cosine), matching-based (Jaccard, Dice, Overlap),
intersection, fidelity / squared-chord, and entropy-based (Kullback–Leibler,
Jensen–Shannon). For Unit 1, focus on Euclidean, Manhattan and Cosine.
Machine Learning · Unit 1 — Exam Preparation Page 6
PART 3 Introduction to Machine Learning
3.1 What Is Machine Learning?
Machine Learning (ML) is a branch of Artificial Intelligence that enables computer systems to
learn patterns from data and improve their performance on a task without being explicitly
programmed with fixed rules for every scenario.
• Learns from examples (data) rather than hard-coded instructions.
• Improves automatically as more data becomes available.
• Identifies patterns too complex for manual rule-writing.
• Powers predictions, classifications and decisions.
How machines learn: Data → Algorithm → Model → Prediction (on new, unseen data).
3.2 Traditional Programming vs Machine Learning
Traditional Programming Machine Learning
Rules + Data → Output Data + Output → Rules (Model)
Developer writes explicit, fixed logic Algorithm discovers patterns/rules from examples
Behaviour is predictable, pre-defined Behaviour improves as more data is provided
Struggles with complex, ambiguous patterns Handles complex, high-dimensional patterns well
e.g. if-else rules for tax calculation e.g. a model that learns to detect spam emails
3.3 Why Machine Learning Matters
ML quietly powers everyday tools: Healthcare (diagnosis, medical imaging, drug discovery),
E-Commerce (recommendations, demand forecasting), Transport (self-driving, route
optimisation), Security (fraud detection), Communication (translation, chatbots, voice
assistants) and Entertainment (personalised streaming).
3.4 Types of Machine Learning
1. Supervised Learning
Learns a mapping from inputs (features) to known outputs (labels) using a labelled training
set, then applies it to new data.
• Classification — predicts a discrete category. e.g. Spam vs Not-Spam, Disease diagnosis,
Flight delayed (0/1).
• Regression — predicts a continuous value. e.g. House price, Temperature forecast, Ticket
price.
• Algorithms: Linear & Logistic Regression, Decision Trees, Random Forest, SVM, KNN, Neural
Networks.
2. Unsupervised Learning
Explores unlabelled data to discover hidden patterns, groupings or structure — with no
predefined correct answers.
• Clustering — groups similar points (customer segmentation, document grouping).
• Dimensionality Reduction — fewer features, keep information (PCA; visualisation, noise
reduction).
• Association — co-occurrence patterns (market-basket analysis).
• Algorithms: K-Means, Hierarchical Clustering, DBSCAN, PCA, Apriori.
Machine Learning · Unit 1 — Exam Preparation Page 7
3. Reinforcement Learning
An agent learns by performing actions within an environment and receiving rewards or
penalties, gradually learning the strategy (policy) that maximises long-term reward.
• Key terms: State (current situation), Action (a choice), Reward (feedback +/−), Policy
(strategy for choosing actions).
• Examples: game-playing AI (Chess, Go), robotics control, autonomous vehicles, traffic
management.
3.5 The Machine-Learning Workflow
Building an ML solution follows a structured, iterative sequence:
Problem Definition → Data Collection → Data Preprocessing → Model
Training → Evaluation → Deployment
It is iterative — insights from evaluation often lead back to data collection or model refinement.
3.6 Key Terminology
Term Meaning
Feature An individual measurable input variable used by the model
Label The target output a supervised model learns to predict
Model The mathematical function learned from data
Training data Data used to teach the model patterns
Test data Unseen data used to evaluate model performance
Overfitting Model memorises training data but fails on new data
Underfitting Model is too simple to capture the underlying pattern
Hyperparameter A configuration value set before training begins
Accuracy The proportion of correct predictions made by a model
3.7 Challenges in Machine Learning
• Data quality & quantity — needs large, clean, representative, well-labelled data.
• Overfitting & generalisation — good on train, poor on real-world data.
• Bias & fairness — models can inherit and amplify biases in the data.
• Interpretability — complex models act as 'black boxes'.
• Computational cost — significant processing power, time and energy.
• Privacy & security — sensitive training data raises consent/misuse concerns.
Machine Learning · Unit 1 — Exam Preparation Page 8
PART 4 Data Preprocessing & Normalization (in
depth)
4.1 Why Preprocess?
Raw data is messy — missing values, duplicates, outliers, inconsistent formats and different
scales. Models trained on raw data fail or mislead ("garbage in, garbage out"). Preprocessing
converts raw data → model-ready data.
Raw Data → Data Exploration → Missing Values → Outliers → Encoding
→ Feature Scaling → Feature Selection → Splitting → Model-Ready
Data
4.2 Handling Missing Values
Detect with [Link]().sum() (isnull() and isna() are identical). Then choose a strategy:
Strategy When to use Code
Drop rows Very few missing (< 5%) [Link]()
Drop column Column > 50% missing [Link](col, axis=1)
Mean imputation Numeric, symmetric data SimpleImputer(strategy='mean')
Median imputation Numeric, skewed / outliers SimpleImputer(strategy='median')
Mode imputation Categorical columns SimpleImputer(strategy='most_frequent')
KNN imputation Complex patterns KNNImputer(n_neighbors=5)
Constant Domain-specific fill SimpleImputer(strategy='constant')
4.3 Handling Outliers
An outlier is a value far outside the typical range of a variable. Outliers distort statistics (mean,
std) and can mislead model training.
Method Rule / Formula Best for
IQR method outlier if < Q1 − 1.5×IQR or > Q3 + 1.5×IQR Skewed data
Z-Score flag if |z| > 3, where z = (x − μ)/σ Normal distributions
Box Plot visual inspection Quick exploration
Treatment: removal, capping (clip to a limit), or mathematical transformation (e.g. log).
4.4 Data Encoding (Categorical → Numeric)
ML algorithms work with numbers, not text, so categorical columns must be converted.
Method When to use Example
Label Encoding Ordinal categories (A > B > C) Grade: A=2, B=1, C=0
One-Hot Encoding Nominal categories (no order) City → separate 0/1 columns
Ordinal Encoding Manually defined order Low=0, Medium=1, High=2
Binary Encoding High-cardinality nominal Saves space vs One-Hot
Machine Learning · Unit 1 — Exam Preparation Page 9
4.5 Feature Scaling — Overview
Algorithms like KNN, SVM, K-Means and Neural Networks are distance- /
gradient-sensitive. A feature ranging 0–10,000 will dominate one ranging 0–1 unless scaled.
Method Formula Output range Best for
Min-Max (Normalisation) (x − min)/(max − min) [0, 1] Bounded, no outliers
Z-Score (Standardisation) (x − μ)/σ ≈ [−3, 3] Normally distributed
Robust Scaler (x − median)/IQR varies Data with outliers
Log Transform log(x + 1) varies Highly skewed data
Which models do NOT need scaling? Tree-based models — Decision Tree, Random Forest,
XGBoost — split on thresholds, so they are scale-invariant.
4.6 Normalization Techniques (the Lab-2 core)
A) Min-Max Normalization
Definition: scales values to a fixed range, usually 0–1.
Xnorm = (X − Xmin) / (Xmax − Xmin)
where X = original value, Xmin / Xmax = minimum / maximum of the feature, Xnorm = normalized
value.
• Advantages: simple; preserves relationships among values; bounded output good for
neural-network inputs and image pixels.
• Disadvantages: very sensitive to outliers (one extreme value squashes the rest); a new
value outside the train min/max can fall outside [0, 1].
B) Z-Score Normalization (Standardization)
Definition: transforms data so that it has mean = 0 and standard deviation = 1. The Z-value
tells how many standard deviations a value is from the mean.
Z = (X − μ) / σ
where μ = mean of the feature, σ = standard deviation of the feature, Z = standardized value.
• Advantages: less affected by outliers than Min-Max; suited to algorithms that assume
normally-distributed data; commonly used with SVM, Logistic Regression and PCA.
• Disadvantages: does not restrict values to a fixed range; output is less intuitive to read.
C) Min-Max vs Z-Score — Comparison
Aspect Min-Max Z-Score
Formula (X − min)/(max − min) (X − μ)/σ
Output Bounded [0, 1] Mean 0, std 1 (unbounded)
Outliers High sensitivity Lower sensitivity
Best for Bounded data, image pixels, NN inputs Normal data, SVM, LR, PCA
Shape Preserved (rescaled) Preserved (re-centred + rescaled)
Which is best for the Airways domain? Flight data (delays, fares) is usually skewed and contains
outliers, so Z-Score is generally more suitable because it is less distorted by extreme values. (If
the data were clean and bounded, Min-Max would be justified — be ready to argue either way.)
Machine Learning · Unit 1 — Exam Preparation Page 10
PART 5 LAB 1 — Exploratory Data Analysis (EDA)
5.1 What EDA Is, and Why We Do It
Exploratory Data Analysis is the process of understanding a dataset's structure, quality,
patterns and relationships before any modelling. It answers "what does my data actually look
like?" and exposes problems (missing values, duplicates, outliers, redundant features) early, so
the model is trained on trustworthy data.
Quote to remember: "Observation and the search for similarities and differences are the basis of all
human knowledge." — EDA is exactly that, applied to data.
5.2 The Four Parts Explained (100%)
Part A — Dataset Understanding
Establish the basics: the domain, number of records (rows) and attributes (columns), each
feature's data type, and the target variable (what you would predict). For an Airways dataset
the target could be Price (regression) or Is_Delayed (classification).
Part B — Data Quality Assessment
Check completeness and reliability: missing values, duplicate records, and inconsistent /
invalid entries (e.g. negative delay, impossible duration). Decide how to fix each — this directly
feeds the cleaning step.
Part C — Feature Analysis
Identify the most significant features, categorise each as numerical / categorical / ordinal /
binary, judge relevance to the problem, and spot redundant or highly correlated features.
Suggest transformations (e.g. scaling, encoding, new derived features).
Part D — Insight Generation
Summarise key findings, trends and relationships using visualisations, then state the
domain implications and recommend the next ML task. This is where EDA pays off.
5.3 Why Each Plot Is Used
Plot What it reveals
Histogram Distribution / shape of a single numeric feature (skew, spread)
Box Plot Outliers and quartile spread of a feature
Scatter Plot Relationship between two numeric features
Heatmap Correlation (−1 to +1) between all numeric features → spot redundancy
5.4 Pseudocode
Machine Learning · Unit 1 — Exam Preparation Page 11
BEGIN EDA
IMPORT pandas, numpy, matplotlib, seaborn
// PART A - Dataset Understanding
LOAD dataset INTO df
PRINT [Link] // (records, attributes)
PRINT [Link]() // preview rows
PRINT [Link]() // column names + data types + non-null counts
PRINT [Link]() // mean, std, min, max, quartiles
IDENTIFY target variable
// PART B - Data Quality
PRINT [Link]().sum() // missing values per column
PRINT [Link]().sum() // count duplicate rows
CHECK invalid entries // negative delays, impossible values
// PART C - Feature Analysis
SPLIT columns INTO numerical AND categorical
COMPUTE correlation matrix (numerical only)
IDENTIFY redundant / highly-correlated features
// PART D - Insight Generation
PLOT histogram, boxplot, scatter, heatmap
SUMMARISE key findings, trends, relationships
END EDA
5.5 Annotated Code
import pandas as pd
import numpy as np
import [Link] as plt
import seaborn as sns
# ---- PART A: Dataset Understanding ----
df = pd.read_csv('[Link]')
print('Shape:', [Link]) # rows = records, cols = attributes
print([Link]()) # first 5 rows
print([Link]()) # data types + non-null counts
print([Link]()) # statistical summary of numeric columns
# ---- PART B: Data Quality ----
print([Link]().sum()) # missing values per column
print('Duplicates:', [Link]().sum())
df = df.drop_duplicates() # remove duplicate rows
df['Arrival_Delay'] = df['Arrival_Delay'].fillna(df['Arrival_Delay'].median())
# ---- PART C: Feature Analysis ----
num_cols = df.select_dtypes(include=[Link]).columns
cat_cols = df.select_dtypes(include='object').columns
print('Numerical:', list(num_cols))
print('Categorical:', list(cat_cols))
corr = df[num_cols].corr() # correlation matrix
# ---- PART D: Insights / Visualisation ----
df['Price'].hist(bins=20); [Link]('Price Distribution'); [Link]()
[Link](x=df['Arrival_Delay']); [Link]('Delay Outliers'); [Link]()
[Link](x='Distance', y='Price', data=df); [Link]()
[Link](corr, annot=True, cmap='Blues'); [Link]()
5.6 Viva Questions — Lab 1
Machine Learning · Unit 1 — Exam Preparation Page 12
Question Answer
Exploring a dataset's structure, quality, patterns & relationships before
What is EDA?
modelling.
Which functions explore data? shape (size), head() (preview), info() (types), describe() (stats).
Check & handle missing values? [Link]().sum(); then drop (if few) or impute (mean/median/mode).
Mean vs Median vs Mode Mean → symmetric numeric; Median → skewed/outliers; Mode →
imputation? categorical.
Find / remove duplicates? [Link]().sum() to count; df.drop_duplicates() to remove.
What is the target variable? The output/label the model predicts (e.g. Price, or Delayed 0/1).
Strength & direction of correlation between numeric features; spots
What does a heatmap show?
redundancy.
Which plot for outliers? Box plot (also IQR rule or Z-score).
isnull() vs isna()? Identical — they are aliases.
Machine Learning · Unit 1 — Exam Preparation Page 13
PART 6 LAB 2 — Normalization (Min-Max &
Z-Score)
6.1 What & Why (Concept)
Normalization rescales numeric features onto a comparable scale so that no single
large-magnitude feature dominates distance- or gradient-based algorithms. The objective of Lab
2 is to apply Min-Max and Z-Score normalization to the numeric attributes of a domain dataset
and analyse the effect on the values.
Why the Airways dataset needs it: features sit on very different scales — Distance 500–5000
km, Price ₹2000–50000, Duration 30–600 min, Stops 0–2. Without scaling, KNN / K-Means / SVM
would be driven almost entirely by Price and Distance. Normalization makes every feature
contribute fairly.
6.2 The Four Parts Explained (100%)
• Part A — Dataset Understanding: identify the domain, list numerical vs categorical
attributes, and explain why normalization is required (scale differences).
• Part B — Data Preparation: load & inspect data, handle missing values, remove duplicates,
and create before/after visualisations (bar, box, line).
• Part C — Normalization: apply Min-Max (scale to 0–1, compare original vs normalized) and
Z-Score (mean 0, std 1, analyse the distribution).
• Part D — Analysis: compare the two techniques and justify which is most suitable for the
domain.
6.3 Pseudocode
Min-Max
BEGIN MIN-MAX
FOR each numerical column X:
X_min <- minimum of column
X_max <- maximum of column
FOR each value x in column:
X_norm <- (x - X_min) / (X_max - X_min)
END FOR
END FOR
// every value now lies between 0 and 1
END
Z-Score
BEGIN Z-SCORE
FOR each numerical column X:
mu <- mean of column
sigma <- standard deviation of column
FOR each value x in column:
Z <- (x - mu) / sigma
END FOR
END FOR
// column now has mean = 0 and std = 1
END
6.4 Annotated Code
Machine Learning · Unit 1 — Exam Preparation Page 14
import pandas as pd, numpy as np
from [Link] import MinMaxScaler, StandardScaler
df = pd.read_csv('[Link]')
df = df.drop_duplicates()
num_cols = ['Distance', 'Price', 'Duration', 'Arrival_Delay']
df[num_cols] = df[num_cols].fillna(df[num_cols].median())
# ---- Min-Max Normalization (0 to 1) ----
mm = MinMaxScaler()
df_minmax = [Link](mm.fit_transform(df[num_cols]), columns=num_cols)
# pandas equivalent:
# df_minmax = (df[num_cols] - df[num_cols].min()) / \
# (df[num_cols].max() - df[num_cols].min())
# ---- Z-Score Normalization (mean 0, std 1) ----
zs = StandardScaler()
df_zscore = [Link](zs.fit_transform(df[num_cols]), columns=num_cols)
# pandas equivalent (NOTE: .std() uses sample std, ddof=1):
# df_zscore = (df[num_cols] - df[num_cols].mean()) / df[num_cols].std()
print(df_minmax.describe()) # min 0, max 1
print(df_zscore.describe()) # mean ~0, std ~1
fit vs transform: fit learns the parameters (min/max or mean/std); transform applies them. On
test data use transform only (parameters learned from train) to avoid data leakage.
6.5 Worked Manual Calculations (memorise)
Min-Max — slide example
marks = [20, 40, 60, 80, 100], find the normalized value for X = 60:
X_min = 20, X_max = 100
X_norm = (60 - 20) / (100 - 20) = 40 / 80 = 0.5
Z-Score — slide example
values = [10, 20, 30, 40, 50], find Z for X = 40:
mu = (10+20+30+40+50)/5 = 30
sigma = sqrt[ ((-20)^2 + (-10)^2 + 0^2 + 10^2 + 20^2) / 5 ]
= sqrt[ (400+100+0+100+400)/5 ] = sqrt[1000/5] = sqrt(200) ~= 14.14
Z = (40 - 30) / 14.14 = 10 / 14.14 ~= 0.707
The slide uses population std (divide by N) → σ ≈ 14.14 and Z ≈ 0.707, which matches [Link] and
StandardScaler. If you instead use pandas .std() (sample std, divide by N−1) you get σ ≈ 15.81 —
be ready to explain this difference.
Airways example (same method)
Distance (km) = [500, 1000, 1500, 2000, 2500].
Min-Max for 1500: (1500 - 500) / (2500 - 500) = 1000 / 2000 = 0.5
Z-Score for 2000: mu = 1500, sigma = sqrt(500000) ~= 707.1
Z = (2000 - 1500) / 707.1 ~= 0.707
6.6 Viva Questions — Lab 2
Machine Learning · Unit 1 — Exam Preparation Page 15
Question Answer
Normalization vs Standardization? Min-Max → fixed range [0,1]; Z-Score → mean 0, std 1.
Min-Max formula & range? (X−min)/(max−min); output [0, 1].
Z-Score formula & meaning? (X−μ)/σ; mean 0, std 1 — std-deviations from the mean.
Min-Max → bounded/no outliers; Z-Score → normal data / outliers / SVM,
When Min-Max vs Z-Score?
LR, PCA.
Which is better with outliers? Z-Score (between these two). Robust Scaler is best overall.
Which algorithms need scaling? KNN, SVM, K-Means, Neural Networks, PCA, Logistic Regression.
Which do NOT? Decision Tree, Random Forest, XGBoost (threshold splits).
fit learns params; transform applies; fit_transform does both. Test =
fit vs transform vs fit_transform?
transform only.
Why transform-only on test? Using test stats causes data leakage → over-optimistic results.
Does scaling change distribution
No — it only rescales/shifts; relative shape is preserved.
shape?
Why might your sum differ from
Population std (÷N, sklearn) vs sample std (÷N−1, pandas).
sklearn?
Machine Learning · Unit 1 — Exam Preparation Page 16
PART 7 Rapid Revision & Formula Sheet
Formula Sheet
Min-Max: Xnorm = (X − Xmin) / (Xmax − Xmin) → [0, 1]
Z-Score: Z = (X − μ) / σ → mean 0, std 1
Euclidean: d = √[ Σ (x₂ᵢ − x₁ᵢ)² ]
Cosine: cos(θ) = (A · B) / (‖A‖ · ‖B‖)
IQR outlier: x < Q1 − 1.5·IQR or x > Q3 + 1.5·IQR
Population σ = √[ Σ(x − μ)² / N ] Sample σ = √[ Σ(x − μ)² / (N − 1) ]
60-Second Recap
• Min-Max → [0,1], hurt by outliers. Z-Score → mean 0 / std 1, better with outliers.
• Scale for KNN, SVM, K-Means, NN, PCA, Logistic Regression; skip for tree models.
• fit learns, transform applies, test = transform only (no data leakage).
• EDA order: understand → quality → features → insights.
• Imputation: median for skewed, mode for categorical, mean for symmetric.
• Outliers: IQR, Z-score (|z|>3), box plot.
• Attribute types: Nominal, Binary, Ordinal, Numeric (Interval / Ratio); Discrete vs Continuous.
• ML types: Supervised (labelled), Unsupervised (unlabelled), Reinforcement (reward).
• A metric needs 4 rules: non-negativity, identity, symmetry, triangle inequality.
• Key sums to memorise: (60 in 20–100) → 0.5; (40 in 10–50) → 0.707.
You've got this. Walk in knowing the two formulas cold, the fit/transform leakage point, and
which algorithms need scaling — those three carry most of the practical viva.
Machine Learning · Unit 1 — Exam Preparation Page 17