AKTU Machine Learning Complete Notes
AKTU Machine Learning Complete Notes
Cross-Verification Note
✅ All topics in these notes have been cross-verified against the official AKTU syllabus
(BOE073/KOE073 Machine Learning)
Source: AKTU 2023-24, 2024-25, 2025-26 Syllabus for [Link] Computer Science Engineering
(CSE)
Real-World Example
Spam Email Detection:
Input: Email text, sender, subject
Output: Spam / Not Spam
How it learns: ML model studies thousands of labeled emails and learns patterns of
spam vs. legitimate emails
1.2 Types of Machine Learning
1.2.1 Supervised Learning
Definition: Model trained on labeled data (input-output pairs). Goal: Learn a function that
maps input → output[1].
Two Subcategories:
Common Tasks:
Clustering: Group similar data points (e.g., customer segmentation)
Dimensionality Reduction: Reduce features while preserving information
Anomaly Detection: Find unusual/outlier data
Example: Photo tagging with few manually tagged photos and many untagged photos in
database.
Learning Verification: If accuracy improves from 80% to 95% as more training data is
added → Program is Learning!
Solutions:
Use more training data
Reduce model complexity
Use regularization (L1, L2 penalties)
Early stopping
Issue 2: Underfitting
Definition: Model is too simple to capture underlying patterns in data[1].
Consequence:
Poor accuracy on both training and test data
High bias, low variance
Solution:
Solutions:
Collect balanced, representative data
Data cleaning
Bias detection and mitigation techniques
Issue 4: Scalability
Definition: Algorithms must handle large datasets and high-dimensional data
efficiently[3].
Challenge:
Computational cost grows with data size
Memory constraints
Training time can be prohibitive
Solutions:
Distributed computing
Efficient algorithms
Hardware acceleration (GPUs, TPUs)
Challenge:
Finding optimal hyperparameters manually is tedious
Too many combinations to test
Solutions:
Grid Search
Random Search
Bayesian Optimization
Solution:
Dimensionality Reduction (PCA, LDA)
Feature Selection
Hypothesis Space
Definition: Set of all possible concepts/hypotheses that could explain the data[1].
A hypothesis h1 is more general than h2 if h1 covers more instances than h2.
Algorithm Steps
Initialization: Start with the most specific hypothesis possible: h = [∅, ∅, ∅, ∅]
For Each Positive Example:
Limitations of Find-S
1. Ignores negative examples → may find a hypothesis that also covers some negative
examples
2. No mechanism to avoid overfitting
3. Cannot detect inconsistencies
4. Limited hypothesis space → works only with conjunction of attributes
If a hypothesis correctly classifies all training examples → it's in the version space
As more data arrives → version space shrinks
Representation: General and Specific Boundaries
General Boundary (G): Set of most general hypotheses in version space
Specific Boundary (S): Set of most specific hypotheses in version space
Version Space: All hypotheses between S and G
1. Remove from G any hypothesis that does NOT cover this example
2. Generalize S minimally to include this example
If Example is NEGATIVE (c = No):
1. Remove from S any hypothesis that COVERS this example
2. Specialize G minimally to exclude this example
Mathematical Model
For a single feature:
Where:
= number of training examples
= actual output for example
= predicted output
Where:
Sigmoid Function
Properties:
Output range: [0, 1]
Smooth S-shaped curve
Interpretable as probability
Decision Rule:
If → predict Class 1
If → predict Class 0
2.3 Perceptron
Overview
The Perceptron is the simplest neural network—a single-layer classifier for linearly
separable binary classification[1].
Architecture
Input Layer → Weights → Summation → Activation → Output
Mathematical Model
Weighted Sum:
Activation (Step Function):
Limitations
Cannot solve XOR problem (not linearly separable)
Only binary classification
Sensitive to feature scaling
Margin
Definition: Distance from the separating hyperplane to the nearest data point[1].
Intuition:
Larger margin = more confident separation = better generalization
SVM maximizes margin to improve robustness
Mathematical Formulation
For binary classification with labels :
Objective: Maximize margin
Constraints:
Decision Function
If → Class +1
If → Class -1
Support Vectors
Definition: Data points that lie on the margin boundary (closest to hyperplane)[1].
Importance:
Only support vectors matter for the final model
Other points can be removed without changing the boundary
Solution: Kernel Trick – map data to higher dimension where it becomes separable[2].
Common Kernels:
Linear Kernel:
Polynomial Kernel:
RBF (Gaussian) Kernel:
Advantages of SVM
Effective in high dimensions
Memory efficient (support vectors)
Kernels handle non-linear data
Theoretically well-founded
Disadvantages
Slow for very large datasets
Requires feature scaling
Not ideal for multi-class
Kernel Function
A kernel function computes the similarity between two points:
Disadvantages
Choosing right kernel is challenging
Kernel parameters need tuning
Less interpretable than linear models
Advantages
Easy to understand and interpret
Handles both classification and regression
No feature scaling needed
Fast predictions
Disadvantages
Prone to overfitting
Small changes in data can drastically change tree
Biased toward features with many values
Where:
= proportion of class in set
= number of classes
Entropy Interpretation
Entropy = 0: All examples belong to one class (pure)
Entropy = 1: Equal mix of two classes (maximum uncertainty)
0 < Entropy < 1: Mixed classes (some uncertainty)
Information Gain
Definition: Reduction in entropy after splitting on an attribute[1].
ID3 Algorithm
1. Start at root with all training data.
2. For each attribute, calculate Information Gain.
Stopping Criteria
All examples in subset belong to one class (pure)
No more attributes to split on
Subset is empty
Maximum tree depth reached
Solutions:
Remove rows with missing values
Impute with mean, median, or most frequent value
Distribute example across branches proportionally
Issue 5: Fragmentation
Problem: Deep trees split data into very small subsets[2].
Consequence:
Difficult to learn patterns from few examples
High variance in deeper nodes
Solution:
Set minimum samples required to split a node
Limit tree depth
Two Approaches
Pre-Pruning (Early Stopping)
Done during tree construction.
Stop splitting when:
Post-Pruning
Done after tree construction.
Process:
1. Build full tree on training data
2. For each non-leaf node:
Remove its subtree
Replace node with most frequent class label
Evaluate on validation set
If validation accuracy improves → keep pruned version
Else → restore subtree
3. Repeat until no improvement
Advantages:
Process
1. For each path from root to leaf:
Collect all attribute-value conditions along path
Create IF-THEN rule
2. Simplify rules (optional):
Remove redundant conditions
Combine similar rules
Applications
Expert systems
Rule-based decision making
Knowledge discovery
Business intelligence
Biological Inspiration
Biological Neuron:
Dendrites receive signals
Body processes signals
Axon transmits output
Artificial Neuron:
Inputs
Weights (connection strengths)
Bias
Summation
Activation function
Output
Activation Functions
Why needed: Without activation, stacking layers remains linear[1].
Sigmoid Function
Algorithm
Initialize: , learning rate (e.g., 0.1)
For each training epoch:
For each training example (x, y_true):
1. Compute prediction:
2. Compute error:
3. If error ≠ 0:
Update:
Until: Convergence (no errors) or max iterations.
Multi-Layer Architecture
Input Layer → Hidden Layers → Output Layer
Each layer transforms data through weighted connections and activation functions.
Forward Propagation
Layer 1 (Hidden):
Layer 2 (Hidden):
Output Layer:
Loss Function
For classification (cross-entropy):
Key Hyperparameters
Why Deep?
Benefits:
Learn hierarchical representations (simple → complex features)
Automatic feature engineering (no manual feature design)
Better performance on complex tasks (images, NLP, speech)
Example: Image Recognition
Layer 1: Detects edges
Layer 2: Detects shapes
Layer 3: Detects objects
Layer 4: Detects faces/people
Output: High-level concept identification
Popular Deep Architectures
Architec
Purpose Use Case
ture
Feature extraction from Image classification, object
CNN
images detection
Sequential data Time series, language
RNN
processing modeling
Long sequences with Speech recognition, machine
LSTM
memory translation
Transfor Parallel sequence
NLP, language translation
mer processing
Autoenc Unsupervised Dimensionality reduction,
oder representation learning anomaly detection
Image synthesis, data
GAN Generate new data
augmentation
Algorithm
Training Phase: Store all training data (no learning).
Prediction Phase for new point :
Distance Metrics
Choosing k
k=1: Very sensitive, prone to overfitting
k=3-5: Good balance (common choice)
k=N: Becomes majority class (underfitting)
Advantages
Simple, easy to implement
No training time
Works for non-linear patterns
Disadvantages
Lazy Learning: Slow prediction (compute all distances)
Memory: Store entire dataset
Feature Scaling: Sensitive to distance metric
High Dimensionality: Curse of dimensionality
3.5.2 Locally Weighted Regression (LWR)
Concept
Instead of uniform influence, weight nearby points higher when fitting local
regression[1].
Idea
For each test point :
1. Weight all training points by distance from
2. Fit weighted linear regression to nearby points
3. Use fitted model to predict
Advantages
Adapts to local patterns
Non-parametric (no global model)
Disadvantages
Expensive (fit regression for each prediction)
Requires careful bandwidth tuning
Hidden layer: N neurons, one per (or subset of) training points
Output layer: Weighted sum of RBF activations
Properties
Local Representation: Each RBF responds to local region
Universal Approximator: Can approximate any function
Interpretable: Basis functions have clear meaning
Advantages
Localized processing
Fast training (compared to ANNs)
Disadvantages
Curse of dimensionality
Center selection non-trivial
4 Rs of CBR
1. RETRIEVE
Find similar past cases to new problem
Use similarity metrics
2. REUSE
Adapt solution from retrieved case
May need adjustment
3. REVISE
Test adapted solution
Modify if needed
4. RETAIN
Store new case and solution
Future reference
Example: Medical Diagnosis
New Patient Problem: Age 45, Fever, Cough, Fatigue
Retrieve: Find similar past patients in database
Reuse: Apply same treatment plan from similar cases
Advantages
Leverages domain knowledge
Explainable (based on past cases)
Works with complex, symbolic knowledge
Disadvantages
Requires good case library
Similarity metric design critical
Scalability (large case bases)
Where:
= Hypothesis
= Data/Evidence
= Prior probability
= Likelihood
= Evidence
= Posterior probability[1]
Intuitive Explanation
Update belief based on evidence:
Decision Rule
For new instance , predict class with maximum posterior probability:
Challenge
Computing exact is expensive with high-dimensional data.
Solution
Naive Bayes = approximate version (next section).
4.4 Naive Bayes Classifier
Key Assumption
Features are conditionally independent given the class[1].
Model
Training
Estimate probabilities from training data[1]:
Prediction
For new instance, compute class probability for each class:
Advantages
Simple, fast training and prediction
Works well despite independence assumption
Requires small training data
Probabilistic output
Disadvantages
Independence assumption often violated
Zero-frequency problem
Laplace Smoothing
Handle zero frequencies by adding 1 to counts[1]:
Representation
Nodes = Random variables
Directed edges = Conditional dependencies
Conditional Probability Tables (CPT) = Local probabilities
Inference
Compute probabilities of interest using the network structure and CPTs.
Advantages
Encodes causal/conditional structure
Efficient representation
Handles uncertainty
Disadvantages
Network structure must be specified
CPT estimation needs data
Inference can be expensive
M-Step (Maximization)
Update model parameters to maximize likelihood
Using expectations from E-step
Iterate
Repeat E and M until convergence[1].
Advantages
Principled probabilistic approach
Handles missing data naturally
Disadvantages
Can converge to local optima
Sensitive to initialization
Computationally expensive
Algorithm
For m = 1 to M:
1. Sample m-th bootstrap sample from training data (with replacement)
2. Train model on bootstrap sample
3. Store model
Prediction: For new instance, get prediction from each model and aggregate.
Bootstrap Sample
Same size as original dataset
Some points repeated, some omitted
Different for each iteration
Benefits
Reduces Variance: Averaging reduces random fluctuations
No increase in Bias: Models trained on full-size samples
Parallel: Different samples can train in parallel
Algorithm
For m = 1 to M:
1. Bootstrap sample training data
2. Grow decision tree:
At each split: Consider random subset of features
Choose best feature from subset
3. Store tree (no pruning)
Parameter Effect
n_trees More trees → better (but slower)
max_features Consider √D features at each split
max_depth Limit tree depth
min_samples_split Minimum points to split node
Advantages
Better than single tree
Handles high-dimensional data
Robust to outliers
Feature importances available
Parallelizable
Disadvantages
Less interpretable (many trees)
Slower prediction
More memory
AdaBoost Algorithm
Initialize: weight for each training example
For t = 1 to T:
Advantages
Strong improvements over weak learners
Combines weak hypotheses → strong hypothesis
Theoretically justified
Disadvantages
Sequential (cannot parallelize)
Sensitive to outliers
Requires careful tuning
Overfitting risk if too many iterations
Method Features
AdaBoost Exponential weights, single weak learner type
Gradient Boosting Fits residuals sequentially
XGBoost Fast, regularized, handles missing data
LightGBM Memory-efficient, fast training
Key Steps
Random initialization of K cluster centers
Assignment step: Assign each point to nearest center
Update step: Recalculate centers as mean of assigned points
Repeat until convergence
Advantages
Simple, fast
Scales well to large datasets
Easy to implement and understand
Disadvantages
Requires specifying K in advance
Sensitive to initialization
Converges to local optimum
Assumes spherical clusters
Advantages
No need to specify number of clusters
Produces interpretable dendrogram
Can capture hierarchical structure
Disadvantages
Computationally expensive
Cannot undo previous merges
Sensitive to outliers
5.1.3 DBSCAN
Density-based approach
For each point[1]:
If many neighbors within radius ε: Core point
Elif near core point: Border point
Else: Noise/Outlier
Advantages
Finds clusters of arbitrary shape
Identifies outliers
No need to specify number of clusters
Disadvantages
Requires tuning radius ε and minimum points
Sensitive to parameter values
Difficult with varying density clusters
Advantages
Unsupervised approach
Reduces computation and memory
Can visualize high-dimensional data
Removes correlated features
Disadvantages
Components not always interpretable
Requires scaling features
May lose important information
Advantages
Supervised (uses class labels)
Good for classification
Better than PCA for classification
Disadvantages
Requires labeled data
Assumes normal distribution
Assumes equal class covariances
Best Practices
Randomize data before splitting
Stratified split for imbalanced datasets
Use test set only at the end
5.3.2 Cross-Validation
k-Fold Cross-Validation
Split data into K folds
For k = 1 to K:
Test on fold k
Train on remaining K-1 folds
Record performance
Average performance across folds[1].
Benefits
Uses all data for both training and testing
More reliable estimate
Good for small datasets
Reduces variance in performance estimate
Variants
Stratified k-fold: Maintains class distribution
Leave-One-Out (LOO): Each fold has one sample
Time-Series Split: Respects temporal order
Predicted + Predicted -
Actual + TP FN
Actual - FP TN
Metrics[1]:
Regression Metrics
MAE (Mean Absolute Error):
RMSE (Root Mean Squared Error):
R² Score: Proportion of variance explained (0-1, higher is better)[1]
5.3.4 ROC and AUC
ROC (Receiver Operating Characteristic) Curve:
X-axis: False Positive Rate
Y-axis: True Positive Rate
Plot at different classification thresholds[1]
AUC (Area Under Curve):
Advantages
Threshold-independent
Good for imbalanced datasets
Visual representation of trade-offs
Key Components
Agent: Decision-maker
Environment: System agent interacts with
State: Current situation
Action: Choice the agent makes
Reward: Feedback signal
Policy: Strategy mapping states to actions
Q-Learning
Goal: Learn Q-function = expected cumulative reward for action in state[1].
Update Rule:
Where:
= learning rate
= discount factor
= immediate reward
= next state
Advantages
Learns optimal policy
Model-free (no environment model needed)
Off-policy learning possible
Disadvantages
Slow convergence
Requires exploration-exploitation trade-off
Sensitive to rewards design
Key Concepts
Population: Set of candidate solutions (genomes)
Fitness: Quality of solution
Selection: Choose best solutions to reproduce
Crossover: Combine two solutions
Mutation: Random change in solution
Algorithm
Initialize: Random population
While not converged:
1. Evaluate fitness of each individual
2. Select fittest individuals
3. Apply crossover (combine two parents)
4. Apply mutation (random changes)
5. Create new population[1]
Advantages
Handles complex, non-linear optimization
No gradient required
Can escape local optima
Parallelizable
Disadvantages
Computationally expensive
No convergence guarantee
Requires careful parameter tuning
Representation design critical
REFERENCES
[1] Mitchell, T. M. (1997). Machine Learning. McGraw-Hill.
[2] Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning. MIT Press.