Machine Learning – Introduction
& Supervised Learning
• Course: Artificial Intelligence
• Instructor: Muhammad Abrar Ashraf
• Focus: Supervised Learning
What is Machine Learning?
• AI that learns from data
• Improves automatically
• Not explicitly programmed
• Used in predictions
• Core part of modern AI
Types of Machine Learning
• Supervised Learning – with labels
• Unsupervised Learning – hidden patterns
• Reinforcement Learning – with rewards
• Today: Supervised
• Later: Others
Supervised Learning Basics
• Uses labeled data
• Goal: Learn mapping function
• Example: hours studied → exam score
• Predict unseen data
• Learning from examples
Examples of Supervised Learning
• Predict exam scores
• Email classification
• Weather prediction
• Medical diagnosis
• Face recognition
Steps in Supervised Learning
• 1. Collect data
• 2. Split train/test
• 3. Choose algorithm
• 4. Train model
• 5. Test accuracy
Types of Problems
• Regression: Predict numbers
• Classification: Predict categories
• Example: score = regression
• Example: spam filter = classification
• Both are supervised
Regression Example
• Input: Hours studied
• Output: Exam score
• Linear relationship
• Equation: y = mx + c
• Simple model
Classification Example
• Input: Email text
• Output: Spam/Not Spam
• Learns from labeled emails
• Predicts new ones
• Uses decision trees, SVMs
Linear Regression (Simple)
• Line fit to data
• Slope m and intercept c
• Minimize error
• Equation: y = mx + c
• Used for prediction
Decision Trees
• Tree structure
• Nodes = questions
• Branches = answers
• Leaves = decision
• Used in classification
K-Nearest Neighbors (KNN)
• Instance-based
• Find k closest neighbors
• Majority vote = class
• Simple but effective
Support Vector Machines (SVM)
• Find separating hyperplane
• Maximizes margin
• Good for classification
• High-dimensional data
• Used in spam detection
Training vs Testing
• Training = teach model
• Testing = unseen data
• Split 80/20
• Avoid overfitting
• Ensures generalization
Overfitting
• Learns too well
• Fails on new data
• Like memorization
• Fix: cross-validation
• Simplify model
Applications of Supervised Learning
• Finance: Credit scoring
• Healthcare: Diagnosis
• Retail: Recommendations
• Security: Fraud detection
• Education: Student performance
Advantages
• Easy to understand
• Effective
• Clear process
• Works with many data types
• Real-world use
Disadvantages
• Needs labeled data
• Risk of overfitting
• Not for unlabeled data
• Slow with big data
• Misses hidden patterns
Key Algorithms Recap
• Linear Regression
• Decision Trees
• KNN
• SVM
• All supervised
Real-World Examples
• Amazon: Recommendations
• Google: Spam filter
• Netflix: Ratings
• Banks: Fraud detection
• Hospitals: Diagnosis
Quiz Question 1
• What type needs labels?
• A) Unsupervised
• B) Reinforcement
• C) Supervised
Quiz Question 2
• Which is regression?
• A) Spam detection
• B) Exam score
• C) Cat vs Dog
Quiz Question 3
• Which algorithm classifies?
• A) Linear Regression
• B) Decision Trees
• C) Both
Summary
• ML learns from data
• Supervised = labeled data
• Regression = numbers
• Classification = categories
• Algorithms: LR, DT, KNN, SVM
End of Lecture
• Next: Unsupervised Learning
• Assignment: Try new dataset
• Quiz: supervised basics
• Practice in Colab
• Thank you!
Thank you