Supervised Learning Practice: Classification and Regression (Lecture 6)
In this lecture, we’ll explore Supervised Learning, understand the difference between Classification and Regression, review popular algorithms, and implement both tasks using scikit-learn.
Table of Contents
{% toc %}
1) What Is Supervised Learning?
Supervised Learning uses input data (X) paired with labels (y) to train a model that can predict the correct output for unseen inputs.
1.1 Classification vs. Regression
Type | Description | Output Examples | Use Cases |
---|---|---|---|
Classification | Predicts a category | Spam/Not spam, species | Spam detection, diagnosis |
Regression | Predicts a continuous value | Price, temperature | House price, sales forecast |
2) Classification
2.1 Concept
- Assigns each input to one of several classes.
- Example: “Is this email spam?”
2.2 Common Algorithms
- Logistic Regression
- Decision Tree
- Support Vector Machine (SVM)
- Random Forest
3) Regression
3.1 Concept
- Predicts a continuous value based on input features.
- Example: “Predict apartment price given size, location, and year built.”
3.2 Common Algorithms
- Linear Regression
- Ridge Regression
- Lasso Regression
- Decision Tree Regression
4) General Supervised Learning Workflow
- Prepare data: Separate features (X) and labels (y)
- Split into training and testing sets
- Choose a model and train it
- Predict on test data
- Evaluate model performance
- Improve results via hyperparameter tuning
5) Lab: Classification Example (Iris Species)
|
|
6) Lab: Regression Example (California Housing Prices)
|
|
7) Evaluation Metrics
Classification
- Accuracy: % of correct predictions
- Precision, Recall, F1 Score
Regression
- MSE / RMSE: Error magnitude
- R² Score: Closer to 1 means better fit
8) Key Takeaways
- Supervised Learning uses labeled data to make predictions.
- Classification predicts categories, Regression predicts continuous values.
- Evaluation metrics differ by task type.
- We implemented both classification and regression with scikit-learn.
9) What’s Next?
In Lecture 7, we’ll cover Unsupervised Learning Practice—Clustering and Dimensionality Reduction techniques.