MODULE 1
Introduction to ML - Machine Learning vs. Traditional Programming, Machine learning
paradigms - supervised, semi-supervised, unsupervised, reinforcement learning.
Basics of parameter estimation - maximum likelihood estimation (MLE) and maximum
aposteriori estimation (MAP), Bayesian formulation.
Supervised Learning - Feature Representation and Problem Formulation, Role of loss
functions and optimization
Regression - Linear regression with one variable, Linear regression with multiple variables -
solution using gradient descent algorithm and matrix method
I. Introduction To Machine Learning
Machine Learning (ML) is a subfield of computer science and artificial intelligence that
focuses on enabling systems to learn patterns and make decisions based on data, without
being explicitly programmed for specific tasks.
The primary goal of ML is to build models that can generalize from historical data and
accurately predict or infer outcomes on new, unseen inputs.
II. Machine Learning vs. Traditional Programming
Traditional programming involves manually writing rules and logic based on human
understanding of the problem. Given a set of inputs and a predefined program, the system
produces the desired output. In contrast, machine learning systems receive both input data
and corresponding output examples and use them to automatically learn a program, or model,
that can map inputs to outputs. Traditional programs are static in behavior, whereas ML
models are dynamic and capable of improving over time as more data becomes available.
1
III. Machine Learning Paradigms
Machine learning methods are generally categorized into four primary paradigms based on
the nature of data and learning objectives.
In supervised learning, the algorithm is provided with input-output pairs, allowing it to learn
a function that maps each input to the correct output.
2
This paradigm is commonly used in applications such as spam detection (classification) and
house price prediction (regression), where historical labeled data is available for training.
Unsupervised learning, on the other hand, deals with data that has no labeled outputs. The
goal here is to identify hidden patterns or structures in the data.
Clustering is a typical example, where similar data points are grouped together, often used in
customer segmentation and social network analysis.
Semi-supervised learning combines a small amount of labeled data with a large amount of
unlabeled data. This approach is particularly useful in domains where labeling data is
expensive or time-consuming.
It is widely used in applications such as web content classification and speech recognition.
Reinforcement learning is based on the interaction between an agent and its environment.
The agent learns to take actions in order to maximize cumulative rewards over time.
The agent receives rewards by performing correctly and penalties for performing incorrectly.
The agent learns without intervention from a human by maximizing its reward and
minimizing its penalty.
This paradigm is used in game-playing algorithms, robotic control, and autonomous systems
like self-driving cars.
Example:
The “problem statement” of the example is to walk, where the child is an agent trying to
manipulate the environment (which is the surface on which it walks) by taking actions (viz
walking) and he/she tries to go from one state (viz each step he/she takes) to another.
The child gets a reward (let’s say chocolate) when he/she accomplishes a submodule of the
task (viz taking couple of steps) and will not receive any chocolate (negative reward) when
he/she is not able to walk.
IV. Introduction to Supervised Learning
Supervised learning is a machine learning paradigm where the algorithm learns a mapping
from input features to output labels using a dataset that includes both. The aim is to train a
model that can make predictions or decisions based on new, unseen data by generalizing from
the examples provided in the training set.
In supervised learning, the dataset is composed of pairs (x,y) where 𝑥 represents the input
features (also known as independent variables), and 𝑦 is the corresponding output label
(dependent variable). The goal is to find a function 𝑓(𝑥) that approximates the relationship
between inputs and outputs as closely as possible.
3
i. Feature Representation
The success of any supervised learning model highly depends on how input data is
represented. Feature representation refers to the process of converting raw data into a
numerical form suitable for model training. Features are the attributes or measurable
properties of the data instances.
Good feature representation helps the model identify relevant patterns and relationships in
the data. Examples include converting text into term frequency vectors, encoding categorical
variables using one-hot encoding, or normalizing numerical values to a fixed scale.
Choosing meaningful features often requires domain knowledge, and in many cases, feature
engineering (manually designing features) or feature selection (choosing the most relevant
features) is necessary to improve model performance.
ii. Problem Formulation
In supervised learning, problem formulation involves defining the type of learning task, the
structure of the input and output, and the objectives of the model.
Formulating the problem correctly includes specifying the input-output relationship, choosing
the model type (e.g., decision tree, linear regression, neural network), and defining the
evaluation metric (e.g., accuracy, mean squared error).
There are two major types of supervised learning problems:
Classification: The output variable is categorical. The model predicts a discrete class label.
For example, classifying emails as 'spam' or 'not spam'.
Regression: The output variable is continuous. The model predicts a numeric value. For
example, predicting house prices based on area and location.
iii. Role of Loss Functions
A loss function or objective function quantifies the difference between the predicted output
of the model and the actual target value.
In essence, the loss function acts as a guide for the model—it tells the model how well or
poorly it is doing, and in which direction it should adjust to improve.
Example: Predicting House Prices (Regression Task)
4
Task: Predict the price of a house based on its size (in square feet).
Let’s say the actual price of a house is ₹50 lakhs, but the model predicts it as ₹40 lakhs.
To evaluate how wrong the prediction is, we use a loss function.
A well-chosen loss function is essential for ensuring the model learns effectively during
training.
iv. Optimization in Supervised Learning
In supervised learning, optimization refers to the process of adjusting the parameters of a
machine learning model so that it can minimize the error (or loss) between the predicted
outputs and the actual labeled outputs in the training data.
In supervised learning, you define a loss function (e.g., Mean Squared Error for regression,
Cross-Entropy for classification) that measures how far off the model's predictions are from
the true labels.
The optimization algorithm adjusts the model parameters (like weights in linear
regression) to minimize this loss.
Common optimization algorithms include:
● Gradient Descent
● Stochastic Gradient Descent (SGD)
● Adam (Adaptive Moment Estimation) – mostly in deep learning
Example: In Linear Regression, the goal is to find the best line (slope mmm, intercept ccc)
that minimizes the difference between predicted and actual values.
5
Regression
Simple Linear Regression
In simple linear regression, the dependent variable depends only on a single independent
variable.
For simple linear regression, the form of the model is: y=w0+w1x
Y is a dependent variable.
X is an independent variable.
w0 and w1 are the regression coefficients.
6
Multiple Linear Regression
• In multiple linear regression, the dependent variable depends on more than one
independent variables.
• For multiple linear regression, the form of the model is:
Y = w0 + w1X1 + w2X2 + w3X3 + …… + wnXn
Here,
• Y is a dependent variable.
• X1, X2, …., Xn are independent variables.
• w0, w1,…, wn are the regression coefficients.
Linear Regression – Solved Example – Matrix Method
7
8
9