Machine Learning Models
Machine Learning Models
A machine learning model is defined as a mathematical representation of the output of the training process. Machine
learning is the study of different algorithms that can improve automatically through experience & old data and build the
model. A machine learning model is similar to computer software designed to recognize patterns or behaviors based on
previous experience or data. The learning algorithm discovers patterns within the training data, and it outputs an ML
model which captures these patterns and makes predictions on new data.
Let's understand an example of the ML model where we are creating an app to recognize the user's emotions based on
facial expressions. So, creating such an app is possible by Machine learning models where we will train a model by
feeding images of faces with various emotions labeled on them. Whenever this app is used to determine the user's mood,
it reads all fed data then determines any user's mood.
Hence, in simple words, we can say that a machine learning model is a simplified representation of something or a
process. In this topic, we will discuss different machine learning models and their techniques and algorithms.
There are various types of machine learning models available based on different business goals and data sets.
o Supervised Learning
o Unsupervised Learning
o Reinforcement Learning
o Classification
o Regression
Unsupervised Learning is also divided into below categories:
o Clustering
o Association Rule
o Dimensionality Reduction
We can implement a supervised learning model on simple real-life problems. For example, we have a dataset consisting
of age and height; then, we can build a supervised learning model to predict the person's height based on their age.
Regression
In regression problems, the output is a continuous variable. Some commonly used Regression models are as follows:
a) Linear Regression
Linear regression is the simplest machine learning model in which we try to predict one output variable using one or more
input variables. The representation of linear regression is a linear equation, which combines a set of input values(x) and
predicted output(y) for the set of those input values. It is represented in the form of a line:
Y = bx+ c.
The main aim of the linear regression model is to find the best fit line that best fits the data points.
Linear regression is extended to multiple linear regression (find a plane of best fit) and polynomial regression (find the
best fit curve).
b) Decision Tree
Decision trees are the popular machine learning models that can be used for both regression and classification problems.
A decision tree uses a tree-like structure of decisions along with their possible consequences and outcomes. In this, each
internal node is used to represent a test on an attribute; each branch is used to represent the outcome of the test. The more
nodes a decision tree has, the more accurate the result will be.
The advantage of decision trees is that they are intuitive and easy to implement, but they lack accuracy.
Decision trees are widely used in operations research, specifically in decision analysis, strategic planning, and mainly
in machine learning.
c) Random Forest
Random Forest is the ensemble learning method, which consists of a large number of decision trees. Each decision tree in
a random forest predicts an outcome, and the prediction with the majority of votes is considered as the outcome.
A random forest model can be used for both regression and classification problems.
For the classification task, the outcome of the random forest is taken from the majority of votes. Whereas in the
regression task, the outcome is taken from the mean or average of the predictions generated by each tree.
d) Neural Networks
Neural networks are the subset of machine learning and are also known as artificial neural networks. Neural networks are
made up of artificial neurons and designed in a way that resembles the human brain structure and working. Each artificial
neuron connects with many other neurons in a neural network, and such millions of connected neurons create a
sophisticated cognitive structure.
Neural networks consist of a multilayer structure, containing one input layer, one or more hidden layers, and one output
layer. As each neuron is connected with another neuron, it transfers data from one layer to the other neuron of the next
layers. Finally, data reaches the last layer or output layer of the neural network and generates output.
Neural networks depend on training data to learn and improve their accuracy. However, a perfectly trained & accurate
neural network can cluster data quickly and become a powerful machine learning and AI tool. One of the best-known
neural networks is Google's search algorithm.
Classification
Classification models are the second type of Supervised Learning techniques, which are used to generate conclusions
from observed values in the categorical form. For example, the classification model can identify if the email is spam or
not; a buyer will purchase the product or not, etc. Classification algorithms are used to predict two classes and categorize
the output into different groups.
In classification, a classifier model is designed that classifies the dataset into different categories, and each category is
assigned a label.
o Binary classification: If the problem has only two possible classes, called a binary classifier. For example,
cat or dog, Yes or No,
o Multi-class classification: If the problem has more than two possible classes, it is a multi-class classifier.
Some popular classification algorithms are as below:
a) Logistic Regression
ogistic Regression is used to solve the classification problems in machine learning. They are similar to linear regression
but used to predict the categorical variables. It can predict the output in either Yes or No, 0 or 1, True or False, etc.
However, rather than giving the exact values, it provides the probabilistic values between 0 & 1.
Support vector machine or SVM is the popular machine learning algorithm, which is widely used for classification and
regression tasks. However, specifically, it is used to solve classification problems. The main aim of SVM is to find the
best decision boundaries in an N-dimensional space, which can segregate data points into classes, and the best decision
boundary is known as Hyperplane. SVM selects the extreme vector to find the hyperplane, and these vectors are known as
support vectors.
c) Naïve Bayes
Naïve Bayes is another popular classification algorithm used in machine learning. It is called so as it is based on Bayes
theorem and follows the naïve(independent) assumption between the features which is given as:
Each naïve Bayes classifier assumes that the value of a specific variable is independent of any other variable/feature. For
example, if a fruit needs to be classified based on color, shape, and taste. So yellow, oval, and sweet will be recognized as
mango. Here each feature is independent of other features.
2. Unsupervised Machine learning models
Unsupervised Machine learning models implement the learning process opposite to supervised learning, which means it
enables the model to learn from the unlabeled training dataset. Based on the unlabeled dataset, the model predicts the
output. Using unsupervised learning, the model learns hidden patterns from the dataset by itself without any supervision.
Unsupervised learning models are mainly used to perform three tasks, which are as follows:
o Clustering
Clustering is an unsupervised learning technique that involves clustering or groping the data points into
different clusters based on similarities and differences. The objects with the most similarities remain in the
same group, and they have no or very few similarities from other groups.
Clustering algorithms can be widely used in different tasks such as Image segmentation, Statistical data
analysis, Market segmentation, etc.
Some commonly used Clustering algorithms are K-means Clustering, hierarchal Clustering, DBSCAN, etc.
Reinforcement Learning
In reinforcement learning, the algorithm learns actions for a given set of states that lead to a goal state. It is a feedback-
based learning model that takes feedback signals after each state or action by interacting with the environment. This
feedback works as a reward (positive for each good action and negative for each bad action), and the agent's goal is to
maximize the positive rewards to improve their performance.
The behavior of the model in reinforcement learning is similar to human learning, as humans learn things by experiences
as feedback and interact with the environment.
Below are some popular algorithms that come under reinforcement learning:
o Q-learning: Q-learning is one of the popular model-free algorithms of reinforcement learning, which is
based on the Bellman equation.
It aims to learn the policy that can help the AI agent to take the best action for maximizing the reward under a specific
circumstance. It incorporates Q values for each state-action pair that indicate the reward to following a given state path,
and it tries to maximize the Q-value.
The answer to this question is No, and the machine learning model is not the same as an algorithm. In a simple way,
an ML algorithm is like a procedure or method that runs on data to discover patterns from it and generate the
model. At the same time, a machine learning model is like a computer program that generates output or makes
predictions. More specifically, when we train an algorithm with data, it becomes a model.
Here’s a detailed explanation of the concepts you mentioned, along with examples and
mathematical formulations for better understanding:
Predicting new observations involves using a trained model to infer the target value for
unseen data. The key steps include:
Training: The model learns patterns from the training data (historical data with known
outputs).
Validation: The model's accuracy is assessed using a validation dataset.
Prediction: The trained model is used to make predictions on unseen (test) data.
Examples:
In supervised learning, predicting house prices based on features like size, location, and
number of bedrooms.
In unsupervised learning, assigning a new data point to one of the discovered clusters.
In reinforcement learning, predicting the best action to take in a given state.
Supervised learning involves learning a mapping f(X)→Yf(X) \to Y from labeled data (X,Y)
(X, Y).
Linear Regression
Mathematical Model:
Where:
K-Means Clustering
K-Means is one of the simplest and most widely used clustering algorithms.
Objective: Partition the data into kk clusters such that data points within a cluster are
similar, and points from different clusters are dissimilar.
Algorithm:
1. Initialize kk centroids randomly.
2. Assign each data point to the nearest centroid using a distance metric (e.g.,
Euclidean distance).
3. Update the centroids by computing the mean of all points assigned to each cluster.
4. Repeat steps 2 and 3 until centroids stabilize or a maximum number of iterations is
reached.
Where:
Applications:
o Customer segmentation.
o Document categorization.
o Image compression.
4. Reinforcement Learning
Reinforcement learning (RL) is different from supervised and unsupervised learning. Here,
an agent learns how to act in an environment to maximize a long-term reward.
Key Concepts:
Types of RL Algorithms:
1. Value-Based:
o Example: Q-Learning.
o Goal: Learn the optimal action-value function: Q(s,a)=R+γmaxaQ(s′,a′)Q(s, a) = R + \
gamma \max_a Q(s', a') Where:
Q(s,a)Q(s, a): Value of taking action aa in state ss.
γ\gamma: Discount factor (importance of future rewards).
2. Policy-Based:
o Example: Policy Gradient Methods.
o Goal: Directly optimize the policy to maximize rewards.
3. Model-Based:
o The agent builds a model of the environment and uses it to plan.
Applications:
Reinforcement
Aspect Supervised Learning Unsupervised Learning
Learning