Machine Learning Fundamentals
🎯 Learning Objectives
- Understand what Machine Learning is and why it matters
- Know Tom Mitchell’s formal definition of ML
- Distinguish between supervised, unsupervised, semi-supervised, and reinforcement learning
- Describe the complete ML pipeline from data collection to deployment
- Master key terminology: features, labels, hypothesis, loss functions, data splits
1. What is Machine Learning?
Machine Learning (ML) is a subfield of Artificial Intelligence that gives computers the ability to learn from data without being explicitly programmed for every possible scenario. Instead of writing rules by hand, we provide the machine with data and let it discover patterns automatically.
“Machine Learning is the field of study that gives computers the ability to learn without being explicitly programmed.”
Consider a spam email filter. A traditional programming approach would enumerate explicit rules (“if subject contains ‘free money’, mark as spam”). An ML approach feeds thousands of labelled emails to an algorithm, which automatically discovers the patterns distinguishing spam from legitimate mail.
GATE DA (Data Science & AI) places significant weight on ML foundations. Questions range from conceptual MCQs about learning paradigms to numerical problems requiring you to compute loss functions, gradients, or evaluation metrics by hand.
2. Tom Mitchell’s Formal Definition
A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E.
This definition is precise and frequently tested in GATE. Let us break it down with examples:
- Task (T): Classify emails as spam or not-spam
- Experience (E): A dataset of emails labelled as spam or not-spam
- Performance (P): Percentage of emails correctly classified (accuracy)
The system “learns” if its accuracy improves as it processes more labelled emails.
- Task (T): Predict the selling price of a house
- Experience (E): Historical data of house features and prices
- Performance (P): Mean Squared Error between predicted and actual prices
Questions may ask you to identify T, E, and P for a given scenario. Be careful: the “experience” is always the data the system learns from, not the act of running the algorithm.
3. Types of Machine Learning
ML algorithms are categorised based on the nature of the training signal (feedback) available to the learner.
3.1 Supervised Learning
The training data consists of input-output pairs (x, y). The algorithm learns a mapping function f: X → Y from inputs to outputs. The “supervisor” provides the correct label for each training example.
- Classification: Output y is a discrete category (e.g., spam/not-spam, digit 0–9)
- Regression: Output y is a continuous value (e.g., house price, temperature)
Examples: Linear Regression, Logistic Regression, Decision Trees, SVMs, Neural Networks, KNN, Naive Bayes.
3.2 Unsupervised Learning
The training data has no labels — only inputs x. The algorithm must discover hidden structure or patterns in the data on its own.
- Clustering: Group similar data points (e.g., K-Means, DBSCAN, Hierarchical)
- Dimensionality Reduction: Reduce the number of features while preserving information (e.g., PCA)
- Association Rules: Discover relationships between variables (e.g., Apriori)
- Density Estimation: Model the underlying probability distribution of the data
3.3 Semi-Supervised Learning
A small amount of labelled data is combined with a large amount of unlabelled data. This is practical because labelling data is expensive. The unlabelled data helps the model understand the data distribution, while the labelled data provides the supervision signal.
Use case: Medical imaging where labelling requires expert radiologists (expensive), but unlabelled scans are abundant.
3.4 Reinforcement Learning
An agent learns by interacting with an environment. Instead of being told the correct answer, the agent receives rewards or penalties for its actions. The goal is to learn a policy that maximises cumulative reward over time.
- Key concepts: State, Action, Reward, Policy, Value Function
- Examples: Game playing (AlphaGo), robotic control, recommendation systems
| Aspect | Supervised | Unsupervised | Semi-Supervised | Reinforcement |
|---|---|---|---|---|
| Labels | All data labelled | No labels | Few labels + many unlabelled | Reward signal |
| Goal | Predict output | Find structure | Predict with limited labels | Maximise reward |
| Feedback | Direct (correct answer) | None | Partial | Delayed (reward) |
| Examples | Classification, regression | Clustering, PCA | Label propagation | Q-learning, SARSA |
4. The Machine Learning Pipeline
Building an ML system involves a systematic pipeline of steps. Understanding this pipeline is essential for both practical ML and GATE conceptual questions.
Data Collection
Gather raw data from various sources: databases, APIs, sensors, web scraping, surveys. The quality and quantity of data directly impacts model performance. Garbage in, garbage out is a fundamental ML principle.
Data Preprocessing
Clean and prepare the data: handle missing values, remove duplicates, fix inconsistencies, encode categorical variables, normalise/standardise numerical features. This step typically consumes 60–80% of an ML project’s time.
Feature Engineering & Selection
Create new informative features from raw data (feature engineering) and select the most relevant features (feature selection). Good features can dramatically improve model performance.
Data Splitting
Split the dataset into training set (60–80%), validation set (10–20%), and test set (10–20%). The training set is used to fit the model, the validation set to tune hyperparameters, and the test set for final unbiased evaluation.
Model Selection
Choose an appropriate algorithm based on the problem type (classification/regression), data characteristics (size, dimensionality, linearity), and requirements (interpretability, speed).
Model Training
Fit the model to the training data by optimising the loss function. The training algorithm adjusts model parameters to minimise the difference between predictions and actual values.
Model Evaluation
Assess model performance on the validation/test set using appropriate metrics (accuracy, precision, recall, F1, MSE, R², etc.). Compare against baselines and alternative models.
Hyperparameter Tuning
Adjust hyperparameters (learning rate, regularisation strength, tree depth, etc.) using techniques like grid search, random search, or Bayesian optimisation. Evaluate each configuration on the validation set.
Deployment & Monitoring
Deploy the final model to production. Continuously monitor its performance for data drift (changes in input distribution) and concept drift (changes in the underlying relationship). Retrain as needed.
5. Key Terminology
Mastering ML vocabulary is critical for understanding textbooks, research papers, and GATE questions.
The measurable properties or attributes of the data used as inputs to the model. Also called independent variables, predictors, or attributes. Denoted as x = (x₁, x₂, …, xₙ) where n is the number of features.
The output value the model is trying to predict. Also called the dependent variable, response, or target. Denoted as y. In supervised learning, labels are provided during training.
Training set: Data used to fit/train the model parameters.
Validation set: Data used to tune hyperparameters and select among candidate models. Not used for training.
Test set: Data held out for final, unbiased evaluation. Never seen during training or tuning.
A hypothesis h(x) is a candidate function that maps inputs to outputs. The hypothesis space H is the set of all possible hypotheses that the learning algorithm considers. For example, in linear regression, H is the set of all linear functions h(x) = w₁x₁ + w₂x₂ + … + wₙxₙ + b.
A function that quantifies the error between the model’s prediction ŷ and the true label y for a single example. The cost function (or objective function) is typically the average loss over all training examples.
Common loss functions:
- Mean Squared Error (MSE): L = (1/n) ∑(yᵢ − ŷᵢ)² — for regression
- Cross-Entropy Loss: L = −(1/n) ∑[yᵢ log(ŷᵢ) + (1−yᵢ) log(1−ŷᵢ)] — for binary classification
- 0-1 Loss: L = 1 if ŷ ≠ y, else 0 — for classification (not differentiable)
Parameters: Internal to the model, learned from data during training (e.g., weights w in linear regression, split thresholds in decision trees).
Hyperparameters: Set before training by the user, not learned from data (e.g., learning rate, number of hidden layers, regularisation strength λ, K in KNN).
The ability of a trained model to perform well on unseen data (not just the training set). A model that performs well on training data but poorly on test data has poor generalisation — this is called overfitting.
6. Parametric vs Non-Parametric Models
| Aspect | Parametric | Non-Parametric |
|---|---|---|
| Assumptions | Assumes a fixed functional form (e.g., linear) | No fixed functional form |
| Parameters | Fixed number, independent of data size | Grows with training data size |
| Training speed | Generally faster | Can be slower for large datasets |
| Data requirement | Works with less data | Needs more data to avoid overfitting |
| Flexibility | Less flexible (may underfit) | More flexible (may overfit) |
| Examples | Linear/Logistic Regression, Naive Bayes, Perceptron | KNN, Decision Trees, SVM with RBF kernel |
7. ML vs Traditional Programming
In traditional programming, a human writes explicit rules: Data + Rules → Output. In Machine Learning, the paradigm is inverted: Data + Output → Rules (Model). The algorithm discovers the rules from data automatically.
- Use ML when: The rules are too complex to code manually (e.g., image recognition), the rules change frequently (e.g., fraud detection), or you have abundant data but no clear algorithm.
- Use traditional programming when: The rules are well-known and simple (e.g., tax calculation), the problem is deterministic, or the system must be fully explainable and auditable.
8. GATE-Style Practice
Q: In Tom Mitchell’s definition, a program learns from experience E with respect to task T and performance measure P. For a chess-playing program that improves by playing against itself, identify T, E, and P.
A: T = Playing chess. E = Games played against itself. P = Percentage of games won against opponents.
Q: Which of the following is NOT a type of unsupervised learning?
(A) Clustering (B) Dimensionality Reduction (C) Regression (D) Association Rule Mining
A: (C) Regression is a supervised learning task because it requires labelled training data (continuous target values).
Q: In semi-supervised learning, the model uses only labelled data for training.
A: False. Semi-supervised learning uses both a small amount of labelled data and a larger amount of unlabelled data.
9. Chapter Summary
- ML enables computers to learn patterns from data rather than following explicit rules
- Mitchell’s definition: A program learns from E (experience) w.r.t. T (task) and P (performance measure)
- Four paradigms: Supervised (labelled data), Unsupervised (no labels), Semi-supervised (few labels), Reinforcement (rewards)
- The ML pipeline has 9 stages from data collection to deployment
- Key distinction: Parameters are learned; hyperparameters are set by the user
- Generalisation — performing well on unseen data — is the ultimate goal