Machine Learning Basics: Supervised, Unsupervised, and Reinforcement Learning (Lecture 2)
This is Lecture 2 of our AI 101 series. We’ll break down three core types of Machine Learning, explore their real-world applications, and finish with a verified scikit-learn lab that runs locally without internet access.
Table of Contents
{% toc %}
1) What Is Machine Learning?
Machine Learning (ML) is the process of teaching computers to learn patterns from data and make predictions without being explicitly programmed with rules.
Instead of telling the computer how to solve a problem, we give it examples (data) and let it find the rules itself.
Everyday ML Examples
- Spam filters: Learn patterns of spam vs. normal emails.
- Speech recognition: Trained on thousands of hours of audio.
- Recommendation engines: Suggest products or content based on user behavior.
- Self-driving cars: Learn road patterns from camera/sensor data.
2) Three Main Types of Machine Learning
2.1 Supervised Learning
Learns from labeled data (input + correct output).
Analogy: Studying with both the questions and the answer key.
Tasks:
- Classification: Predict a category (spam vs. ham).
- Regression: Predict a continuous value (house prices).
Task Type | Output Type | Example |
---|---|---|
Classification | Categorical | Spam/Not spam, Iris species |
Regression | Continuous | Predicting stock prices |
2.2 Unsupervised Learning
Learns from unlabeled data (only inputs, no answers).
Analogy: Grouping similar exam questions without knowing the correct answers.
Tasks:
- Clustering: Group similar data points.
- Dimensionality Reduction: Reduce features while preserving key info.
Method | Description |
---|---|
Clustering | Groups data points based on similarity. |
Dimensionality Reduction | Compresses features while keeping core patterns. |
2.3 Reinforcement Learning
Learns by interacting with an environment: takes an action, gets a reward, and adjusts.
Analogy: Learning to play a game by trial and error to maximize the score.
Applications:
- AlphaGo (Go-playing AI)
- Robotics
- Autonomous driving
3) General ML Development Workflow
- Data Collection: CSV, databases, APIs, etc.
- Data Preprocessing: Handle missing/outlier values, normalize features.
- Model Selection: Choose based on the task type.
- Training: Fit the model to the data.
- Evaluation: Measure performance (accuracy, F1-score, etc.).
- Deployment: Integrate the model into production.
4) Hands-On Lab: Classifying Iris Species
We’ll use scikit-learn’s built-in Iris dataset for a safe, offline, beginner-friendly supervised learning demo.
Setup
1
pip install scikit-learn matplotlib
|
|
Expected Output
|
|
5) Key Takeaways
- Supervised Learning: Learns from labeled data (classification/regression).
- Unsupervised Learning: Finds structure in unlabeled data (clustering/dimensionality reduction).
- Reinforcement Learning: Learns via trial-and-error feedback.
- Hands-on: Successfully trained a simple supervised learning model offline.
6) FAQ (Answer Engine Optimization)
Q1. Which type of ML is most common in business? A. Supervised learning—most business problems have historical labeled data.
Q2. Do I need deep learning for every ML task? A. No. Many tasks are better handled with traditional ML models like logistic regression or random forests.
Q3. Can I mix these learning types? A. Yes, hybrid approaches exist (e.g., semi-supervised learning).
Q4. Does reinforcement learning need huge compute? A. For complex tasks, yes—but simple simulations can run on a laptop.
7) Summary Table
Type | Input Data | Output | Example |
---|---|---|---|
Supervised | Labeled | Prediction | Spam filter, house price |
Unsupervised | Unlabeled | Patterns | Customer segmentation |
Reinforcement | Environment + Reward | Policy | Game AI, robotics |
8) What’s Next?
In Lecture 3, we’ll explore Deep Learning fundamentals, including CNNs for images and RNNs for sequences.