0% found this document useful (0 votes)
38 views2 pages

Supervised Learning Class Notes

These class notes provide an introduction to supervised learning within machine learning, covering key concepts, types, algorithms, and practical applications. It details common algorithms like linear regression, logistic regression, and decision trees, along with evaluation metrics and tools for implementation. The notes also highlight challenges in machine learning and suggest further study resources for students new to the field.

Uploaded by

silviu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

Supervised Learning Class Notes

These class notes provide an introduction to supervised learning within machine learning, covering key concepts, types, algorithms, and practical applications. It details common algorithms like linear regression, logistic regression, and decision trees, along with evaluation metrics and tools for implementation. The notes also highlight challenges in machine learning and suggest further study resources for students new to the field.

Uploaded by

silviu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Machine Learning Class Notes: Introduction to Supervised Learning

Course: Introduction to Machine Learning


Date: August 2025
Instructor: Dr. Jane Carter
Institution: Virtual University of Technology

---

1. Overview of Machine Learning


Machine learning (ML) enables computers to learn from data without explicit
programming. Supervised learning, a core ML paradigm, involves training models on
labeled data to predict outcomes. These notes cover supervised learning
fundamentals, algorithms, and practical applications.

2. Key Concepts
- Labeled Data: Data with input-output pairs (e.g., house sizes and their prices).
- Features: Input variables (e.g., house size, number of bedrooms).
- Target: Output variable to predict (e.g., house price).
- Training: Adjusting model parameters to minimize prediction errors.
- Testing: Evaluating model performance on unseen data.

3. Types of Supervised Learning


- Regression: Predicts continuous values (e.g., predicting temperature).
- Classification: Predicts discrete categories (e.g., spam vs. not spam).

4. Common Algorithms
4.1 Linear Regression
- Purpose: Predict continuous outcomes.
- Model: y = w₀ + w₁x₁ + w₂x₂ + ... + wₙxₙ, where w₀ is the intercept, wᵢ are
weights, and xᵢ are features.
- Example: Predicting house prices based on size (x₁) and location score (x₂).
- Cost Function: Mean Squared Error (MSE) = (1/n)∑(y_pred - y_true)².
- Optimization: Gradient descent adjusts weights to minimize MSE.

4.2 Logistic Regression


- Purpose: Binary classification (e.g., pass/fail).
- Model: Uses the sigmoid function, σ(z) = 1/(1 + e⁻ᶻ), where z = w₀ + w₁x₁ + ... +
wₙxₙ.
- Example: Predicting if a student passes (1) or fails (0) based on study hours and
attendance.
- Cost Function: Log Loss (Binary Cross-Entropy).
- Optimization: Gradient descent.

4.3 Decision Trees


- Purpose: Classification or regression.
- Structure: A tree where nodes represent decisions based on feature values,
leading to a final prediction.
- Example: Classifying emails as spam based on word frequency and sender.
- Advantage: Interpretable, handles non-linear data.
- Disadvantage: Prone to overfitting without pruning.

5. Practical Example: Predicting Student Performance


- Dataset: 100 students, features (study hours, attendance %), target (exam score).
- Steps:
1. Preprocess: Normalize study hours (0–1 scale), handle missing attendance
values.
2. Split Data: 80% training, 20% testing.
3. Model: Train a linear regression model.
4. Evaluation: Calculate MSE on test set (e.g., MSE = 12.5 indicates average
squared error).
5. Interpretation: Study hours have a stronger impact (w₁ = 0.7) than attendance
(w₂ = 0.3).

6. Evaluation Metrics
- Regression: MSE, Root Mean Squared Error (RMSE), R² Score.
- Classification: Accuracy, Precision, Recall, F1 Score.
- Example: A model with 85% accuracy correctly classifies 85/100 samples.

7. Tools and Libraries


- Python: Use scikit-learn for model implementation (e.g., `from
sklearn.linear_model import LinearRegression`).
- Example Code:
```
from sklearn.linear_model import LinearRegression
import numpy as np
X = [Link]([[2, 80], [4, 90], [6, 85]]) # Features: study hours, attendance
y = [Link]([70, 85, 90]) # Target: exam scores
model = LinearRegression()
[Link](X, y)
predictions = [Link]([[3, 82]]) # Predict score for 3 hours, 82% attendance
print(f"Predicted score: {predictions[0]:.2f}")
```
- Other Tools: TensorFlow, PyTorch for advanced models.

8. Challenges and Solutions


- Overfitting: Model performs well on training data but poorly on test data.
Solution: Regularization (e.g., Lasso, Ridge).
- Underfitting: Model is too simple. Solution: Increase model complexity or add
features.
- Data Quality: Missing or noisy data. Solution: Impute missing values, clean
outliers.

9. Applications
- Healthcare: Predicting patient outcomes based on medical history.
- Finance: Credit risk assessment using customer data.
- Marketing: Customer segmentation for targeted campaigns.

10. Further Study


- Read “Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow” by
Aurélien Géron.
- Explore Kaggle datasets for hands-on practice (e.g., Titanic dataset for
classification).
- Join ML communities on X or Reddit for discussions and updates.

---

These notes are intended for students new to machine learning. Practice
implementing these algorithms in Python and analyze real datasets to deepen your
understanding.

Common questions

Powered by AI

Regularization methods such as Lasso (L1 regularization) or Ridge (L2 regularization) are best used when models are experiencing overfitting due to high complexity or multicollinearity among input features. Regularization adds a penalty on the magnitude of the coefficients, helping in reducing variance in predictions and improving the generalization of the model on unseen data .

Increasing model complexity (e.g., using more sophisticated models or deeper networks) can improve a model's ability to capture complex patterns in data, hence reducing underfitting. However, it risks overfitting if the increase is excessive or unjustified by available data . On the other hand, adding relevant features can provide more information for the model to learn from, but care must be taken to avoid multicollinearity, which can lead to misleading coefficients and reduced predictive performance . Both strategies need to be balanced with cross-validation to ensure model generalization .

Missing data in a supervised learning problem can be addressed by imputation methods which fill in missing values with substituted values. Popular techniques include mean or median imputation, forward or backward filling in time series, or model-based imputation using predictive models to estimate missing values based on observed data points . Proper handling of missing data can enhance model accuracy by providing more complete data for learning, reducing bias, and preserving statistical power of the dataset .

Mean Squared Error (MSE) is effective because it emphasizes larger errors by squaring the error terms, which can be beneficial for catching significant underperformance in predictions . However, its scale depenency and sensitivity to outliers can be a disadvantage, as large errors disproportionately affect the metric, potentially distorting model evaluations. Despite this, MSE remains widely used for its straightforward interpretation and mathematical properties conducive for optimization .

Linear regression is used for predicting continuous outcomes based on input features, utilizing a model in the form y = w₀ + w₁x₁ + ... + wₙxₙ, where weights are adjusted to minimize the Mean Squared Error (MSE). Logistic regression, on the other hand, is used for binary classification problems. It employs the logistic sigmoid function, σ(z) = 1/(1 + e⁻ᶻ), to predict probabilities of binary outcomes, with optimization done through minimizing Log Loss or Binary Cross-Entropy using gradient descent .

Overfitting in decision trees can be mitigated through pruning, which reduces the complexity of the final model by removing sections of the tree that provide little power in predicting target variables . Additionally, employing techniques like cross-validation, setting a minimum number of samples required to split a node, or a maximum depth for the tree, can help in reducing overfitting .

Feature normalization is critical because it ensures that all features contribute equally to the model's predictions, preventing some features with larger scales from disproportionately affecting the model's outputs. It typically involves scaling features to a specific range, such as 0 to 1, which can improve the convergence speed of optimization algorithms like gradient descent . In practice, this can be achieved using techniques such as min-max scaling or standardization .

Gradient descent is used to optimize the weights of a linear regression model by iteratively adjusting them to minimize the cost function, typically the Mean Squared Error (MSE). It computes the gradient of the MSE with respect to the weights and updates the weights in the opposite direction of the gradient, proportionate to a learning rate, until convergence is achieved, meaning minimal error .

Decision trees offer interpretability by visually representing decisions made based on feature values, are capable of handling both non-linear data and categorical variables, and do not require feature scaling . However, they are prone to overfitting without techniques such as pruning, and they may not generalize well to unseen data. Decision trees can also be sensitive to small variations in the data, leading to high variance in predictions .

In supervised learning, models are trained on labeled data, meaning the input data is paired with the correct output, such as features paired with their corresponding target values . This label information guides the model's learning process, allowing it to make accurate predictions about unseen data by minimizing error between predicted and actual outcomes. Unsupervised learning lacks such labels and instead focuses on identifying inherent patterns or groupings within input data without predefined outputs .

You might also like