PAGE 1 – Introduction to Machine Learning
What is Machine Learning (ML)?
Machine Learning is a branch of Artificial Intelligence (AI) where computers learn patterns from
data and make decisions without being explicitly programmed.
Example:
Instead of writing rules for pass/fail:
If marks > 40 → Pass
Else → Fail
In ML, the system learns from past data to make the prediction automatically.
Definition:
Machine Learning is the study of algorithms that improve automatically through experience.
PAGE 2 – Importance of Machine Learning
ML is everywhere:
Netflix/Amazon recommendations
Google search ranking
Spam detection
Fraud detection
Self-driving cars
Voice assistants
Benefits:
Automates decision-making
Handles large amounts of data
Improves predictions with experience
PAGE 3 – Traditional Programming vs ML
Traditional Programming Machine Learning
Data + Rules → Output Data + Output → Rules (Model)
Programmer defines logic System discovers patterns
ML is useful when rules are too complex to program manually.
PAGE 4 – Types of Machine Learning
1. Supervised Learning – Data with labels
2. Unsupervised Learning – Data without labels
3. Reinforcement Learning – Learning by reward & punishment
PAGE 5 – Supervised Learning
Definition: Learning from labeled data.
Example: Spam detection
Input: Email content
Output: Spam / Not Spam
Subtypes:
Classification – Predict categories (Discrete output)
Regression – Predict continuous values (Numeric output)
PAGE 6 – Classification
Definition: Predicts a category.
Examples:
Pass/Fail
Spam/Not Spam
Cat/Dog
Output: Discrete labels
PAGE 7 – Regression
Definition: Predicts numeric values.
Examples:
House price prediction
Temperature forecasting
Sales forecasting
Output: Continuous numeric values
PAGE 8 – Unsupervised Learning
Definition: Finds patterns in unlabeled data
Example: Customer segmentation in marketing
Main techniques:
Clustering
Dimensionality reduction
PAGE 9 – Reinforcement Learning
Definition: Learning by interacting with an environment and receiving rewards/punishments
Example:
Game AI
Self-driving cars
Robot navigation
Components: Agent + Environment + Reward
PAGE 10 – Real-Life Applications
Healthcare: Disease prediction
Finance: Fraud detection
Marketing: Customer targeting
Education: Student performance analysis
Transportation: Traffic prediction, self-driving cars
PAGE 11 – Key Terminologies
Dataset: Collection of data used for training
Features: Input variables
Label (Target): Output variable to predict
PAGE 12 – Dataset Structure
Feature 1 Feature 2 Label
5 2 Pass
3 1 Fail
Rows → Observations
Columns → Features
PAGE 13 – Types of Data
1. Numerical Data: Age, Salary, Marks
2. Categorical Data: Gender, City, Yes/No
PAGE 14 – Training and Testing Data
Training data: 70–80% of dataset
Testing data: 20–30% of dataset
Purpose: Ensure model performs well on new data
PAGE 15 – What is a Model?
A model is a function mapping inputs to outputs.
Example: Linear regression:
y = mx + c
Here, the model learns m and c from the data.
PAGE 16 – ML Workflow
1. Collect Data
2. Clean Data
3. Split Data (Train/Test)
4. Train Model
5. Test Model
6. Evaluate Performance
PAGE 17 – Data Collection
Sources of data:
Surveys
Databases
Sensors
Websites
Tip: More quality data → Better model
PAGE 18 – Data Cleaning
Fix common issues:
Missing values
Duplicates
Incorrect values
PAGE 19 – Handling Missing Data
Techniques:
Remove rows with missing values
Fill with mean/median/mode
Predict missing values using other data
PAGE 20 – Feature Scaling
Why needed? Features may have different ranges.
Techniques:
Min-Max Scaling → Scale values to [0,1]
Standardization → Convert to mean 0, standard deviation 1
PAGE 21 – Model Training
Steps:
1. Model predicts output
2. Compare prediction with actual label
3. Calculate error
4. Update model parameters
PAGE 22 – Error
Error = Actual − Predicted
Smaller error → Better model
PAGE 23 – Cost Function
Measures total error
Example: Mean Squared Error (MSE)
MSE = (1/n) Σ (Actual − Predicted)²
PAGE 24 – Overfitting
Model learns training data too well
Performs poorly on new data
Analogy: Memorizing answers without understanding
PAGE 25 – Underfitting
Model too simple
Cannot capture patterns
PAGE 26 – Bias and Variance
Bias: Error due to oversimplified model
Variance: Error due to model being too sensitive
Goal: Balance bias & variance
PAGE 27 – Accuracy (for Classification)
Accuracy = Correct Predictions / Total Predictions
PAGE 28 – Confusion Matrix
Actual\Pred Positive Negative
Positive TP FN
Negative FP TN
TP: True Positive
TN: True Negative
FP: False Positive
FN: False Negative
PAGE 29 – Precision and Recall
Precision = TP / (TP + FP)
Recall = TP / (TP + FN)
Used in medical diagnosis, spam detection
PAGE 30 – F1 Score
F1 = 2 × (Precision × Recall) / (Precision + Recall)
Combines precision & recall
Useful for imbalanced datasets
PAGE 31 – Regression Metrics
MAE: Mean Absolute Error
MSE: Mean Squared Error
R² Score: How well predictions match actual data
PAGE 32 – R² Score
Measures goodness of fit
Range: 0 → 1
Closer to 1 → better model
PAGE 33 – Cross Validation
Split data multiple times
Train/test on different splits
Take average performance → reliable evaluation
PAGE 34 – Feature Engineering
Creating new features from existing ones
Example: Extract month/day/year from a date
PAGE 35 – Encoding Categorical Data
Label Encoding: Convert categories to numbers
One-Hot Encoding: Create binary columns for each category
PAGE 36 – Example ML Problem
Predict student pass/fail
Features: Study hours, Attendance
Label: Pass/Fail
Steps: Collect → Train → Test → Predict
PAGE 37 – Advantages of ML
Automation of tasks
Accurate predictions
Handles large data efficiently
Improves with experience
PAGE 38 – Limitations of ML
Needs large data
Can be biased
Computationally expensive
Hard to interpret sometimes
PAGE 39 – Section Summary
Learned ML basics
Types of ML: Supervised, Unsupervised, Reinforcement
Dataset, features, labels
Training/testing, model evaluation
Overfitting & underfitting
Metrics: Accuracy, Precision, Recall, F1, R²
PAGE 40 – Practice Questions
1. Define Machine Learning
2. Difference between supervised and unsupervised learning
3. Explain overfitting with an example
4. Draw and explain a confusion matrix
5. Why is feature scaling important?