PTU B.
Tech Machine Learning Notes
Modules 1 & 2 – Exam Oriented Detailed Notes
Prepared for quick revision for MST and Final Exams.
MODULE 1 – Introduction to Machine Learning
1. Definition of Machine Learning
Machine Learning (ML) is a branch of Artificial Intelligence that allows computers to learn patterns
from data and improve their performance without being explicitly programmed. It focuses on
building algorithms that can learn from and make predictions on data.
Tom Mitchell Definition:
A program learns from experience (E) with respect to some task (T) and performance measure (P)
if its performance at task T improves with experience E.
Example:
Task (T): Spam Email Detection
Experience (E): Large dataset of emails
Performance (P): Accuracy of spam classification
Traditional Programming vs Machine Learning
Traditional Programming:
Input Data + Program Rules -> Output
Machine Learning:
Training Data + Labels -> Learning Algorithm -> Model
Model + New Data -> Prediction
Machine Learning System Architecture
Training Dataset
|
v
Learning Algorithm
|
v
Model
|
v
Prediction
Types of Machine Learning
Machine learning algorithms are categorized into three main types:
1. Supervised Learning
In supervised learning, the algorithm is trained using labeled data. The correct output is known
during training.
Input + Labels -> Algorithm -> Model -> Prediction
Example: Email -> Spam / Not Spam
2. Unsupervised Learning
In unsupervised learning, the algorithm works on unlabeled data and finds hidden patterns or
structures in the dataset.
Unlabeled Data
|
v
Algorithm
|
v
Clusters / Patterns
3. Reinforcement Learning
In reinforcement learning, an agent interacts with the environment and learns by receiving rewards
or penalties.
Agent -> Action -> Environment
^ |
|------ Reward -------|
Applications of Machine Learning
• Healthcare – disease prediction, medical imaging
• Finance – fraud detection, credit scoring
• E-commerce – product recommendation
• Computer Vision – face recognition
• Natural Language Processing – chatbots and translation
Training Data vs Testing Data
Training data is used to train the machine learning model, while testing data is used to evaluate the
model's performance.
Typical dataset split:
Training Data = 70–80%
Testing Data = 20–30%
Feature Selection
Feature selection is the process of selecting the most relevant features from the dataset for model
training.
Feature Extraction
Feature extraction involves transforming raw data into a reduced set of features that represent the
important information.
Raw Image -> Edge Detection -> Feature Vector
Overfitting
Overfitting occurs when a model learns the training data too well, including noise, and performs
poorly on unseen data.
Training Accuracy = High
Testing Accuracy = Low
Underfitting
Underfitting occurs when a model is too simple to capture the patterns in the data.
Bias-Variance Tradeoff
Model Complexity
Underfit -------- Optimal -------- Overfit
MODULE 2 – Supervised Learning
Supervised Learning Overview
In supervised learning, models learn a mapping function from input variables (X) to output variables
(Y) using labeled training data.
Input (X) -> Learning Algorithm -> Output (Y)
Example: House Size -> House Price
Regression
Regression algorithms predict continuous numeric values.
Linear Regression
Linear regression models the relationship between one independent variable and a dependent
variable using a straight line.
Equation:
Y = β0 + β1X
Where:
Y = predicted value
β0 = intercept
β1 = slope
X = input variable
Graph:
Y
|
| *
| *
| *
|
+---------------- X
Regression Line
Multiple Linear Regression
Y = β0 + β1X1 + β2X2 + ... + βnXn
Example:
Price = β0 + β1(Size) + β2(Location) + β3(Rooms)
Classification
Classification algorithms predict categorical class labels.
Logistic Regression
Logistic Function:
P(Y=1) = 1 / (1 + e^-z)
where z = β0 + β1X
Sigmoid Curve:
1 | ___
| /
0.5|----/
| /
0 |__/
X
K-Nearest Neighbor (KNN)
Steps:
1. Choose value of K
2. Calculate distance from neighbors
3. Select K nearest points
4. Assign majority class
Example Diagram:
Class A = o
Class B = x
o x
o
x * (new point)
x
Decision Tree
Outlook
/ | Sunny Overcast Rain
/ Humidity Wind
/ \ / High Normal Strong Weak
No Yes No Yes
Support Vector Machine (SVM)
Class A: o o o
------------------ Hyperplane
Class B: x x x
SVM finds the optimal hyperplane that maximizes the margin between classes.
Confusion Matrix
Predicted
Yes No
Actual Yes TP FN
Actual No FP TN
Evaluation Metrics
Accuracy = (TP + TN) / (TP + TN + FP + FN)
Precision = TP / (TP + FP)
Recall = TP / (TP + FN)
ROC Curve
True Positive Rate vs False Positive Rate
TPR
| *
| *
| *
+-------------- FPR