Machine learning enables systems to learn from data and improve their performance without being explicitly programmed. There are four major types of machine learning:

1. Supervised Learning
- In supervised learning, the algorithm learns from labelled data (i.e., input-output pairs).
- There is a supervisor or teacher that helps the model learn patterns from training data and make predictions on test data.
Subtypes:
a) Classification:
- Used when the output is discrete (like labels or categories).
- Example: Classifying emails as spam or not spam.
- Algorithms: Decision Tree, Random Forest, Support Vector Machines (SVM), Naive Bayes, Neural Networks.
b) Regression:
- Used when the output is a continuous numeric value.
- Example: Predicting house prices based on square footage.
- Algorithm: Linear Regression (y = mx + b)
Example: Predicting plant species from petal/sepal dimensions using the Iris dataset.
2. Unsupervised Learning
- There are no labels or supervision.
- The system learns by itself by observing patterns and grouping similar data points.
Subtypes:
a) Clustering:
- Groups similar data points into clusters.
- Example: Grouping customer segments, image region detection.
- Algorithms: k-means, Hierarchical clustering.
b) Dimensionality Reduction:
- Reduces the number of features while preserving data patterns.
- Helps in visualization and faster computation.
Example: Grouping animal images (cats and dogs) based on visual similarity without knowing labels.
3. Semi-Supervised Learning
- Uses both labelled and unlabelled data.
- Helpful when labelled data is scarce or expensive to obtain.
- The algorithm learns from unlabelled data by assigning pseudo-labels and combining them with the original labelled data.
Example: Classifying large sets of medical images where only a few are labelled by doctors.
4. Reinforcement Learning
- Involves an agent interacting with the environment and learning through trial and error.
- The agent receives rewards or punishments based on its actions and learns the best strategy over time.
- Used in goal-based learning, where many decisions are taken in a sequence.
Example: A robot navigating a maze to reach the goal while avoiding obstacles and dangers.
If the robot reaches the goal, it gets a positive reward; if it hits a block or danger tile, it gets a negative reward.