0% found this document useful (0 votes)
12 views

Machine Learning Models

Machine learning models are mathematical representations that learn from data to make predictions or recognize patterns. They can be classified into three main types: supervised learning, unsupervised learning, and reinforcement learning, each with specific algorithms and techniques. The choice of model depends on the business requirements, dataset characteristics, and the complexity of the problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Machine Learning Models

Machine learning models are mathematical representations that learn from data to make predictions or recognize patterns. They can be classified into three main types: supervised learning, unsupervised learning, and reinforcement learning, each with specific algorithms and techniques. The choice of model depends on the business requirements, dataset characteristics, and the complexity of the problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

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.

What is Machine Learning Model?


Machine Learning models can be understood as a program that has been trained to find patterns within new data and
make predictions. These models are represented as a mathematical function that takes requests in the form of input data,
makes predictions on input data, and then provides an output in response. First, these models are trained over a set of
data, and then they are provided an algorithm to reason over data, extract the pattern from feed data and learn from those
data. Once these models get trained, they can be used to predict the unseen dataset.

There are various types of machine learning models available based on different business goals and data sets.

Classification of Machine Learning Models:


Based on different business goals and data sets, there are three learning models for algorithms. Each machine learning
algorithm settles into one of the three models:

o Supervised Learning
o Unsupervised Learning
o Reinforcement Learning

Supervised Learning is further divided into two categories:

o Classification
o Regression
Unsupervised Learning is also divided into below categories:

o Clustering
o Association Rule
o Dimensionality Reduction

1. Supervised Machine Learning Models


Supervised Learning is the simplest machine learning model to understand in which input data is called training data and
has a known label or result as an output. So, it works on the principle of input-output pairs. It requires creating a function
that can be trained using a training data set, and then it is applied to unknown data and makes some predictive
performance. Supervised learning is task-based and tested on labeled data sets.

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.

Supervised Learning models are further classified into two categories:

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.

There are two types of classifications in machine learning:

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.

b) Support Vector Machine

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.

o Association Rule Learning


Association rule learning is an unsupervised learning technique, which finds interesting relations among
variables within a large dataset. The main aim of this learning algorithm is to find the dependency of one data
item on another data item and map those variables accordingly so that it can generate maximum profit. This
algorithm is mainly applied in Market Basket analysis, Web usage mining, continuous production, etc.
Some popular algorithms of Association rule learning are Apriori Algorithm, Eclat, FP-growth algorithm.
o Dimensionality Reduction
The number of features/variables present in a dataset is known as the dimensionality of the dataset, and the
technique used to reduce the dimensionality is known as the dimensionality reduction technique.
Although more data provides more accurate results, it can also affect the performance of the
model/algorithm, such as overfitting issues. In such cases, dimensionality reduction techniques are used.
"It is a process of converting the higher dimensions dataset into lesser dimensions dataset ensuring that it
provides similar information."
Different dimensionality reduction methods such as PCA(Principal Component Analysis), Singular Value
Decomposition, 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.

o State-Action-Reward-State-Action (SARSA): SARSA is an On-policy algorithm based on the Markov


decision process. It uses the action performed by the current policy to learn the Q-value. The SARSA
algorithm stands for State Action Reward State Action, which symbolizes the tuple (s, a, r, s', a').
o Deep Q Network: DQN or Deep Q Neural network is Q-learning within the neural network. It is basically
employed in a big state space environment where defining a Q-table would be a complex task. So, in such a
case, rather than using Q-table, the neural network uses Q-values for each action based on the state.

Training Machine Learning Models


Once the Machine learning model is built, it is trained in order to get the appropriate results. To train a machine learning
model, one needs a huge amount of pre-processed data. Here pre-processed data means data in structured form with
reduced null values, etc. If we do not provide pre-processed data, then there are huge chances that our model may perform
terribly.

How to choose the best model?


In the above section, we have discussed different machine learning models and algorithms. But one most confusing
question that may arise to any beginner that "which model should I choose?". So, the answer is that it depends mainly on
the business requirement or project requirement. Apart from this, it also depends on associated attributes, the volume of
the available dataset, the number of features, complexity, etc. However, in practice, it is recommended that we always
start with the simplest model that can be applied to the particular problem and then gradually enhance the complexity &
test the accuracy with the help of parameter tuning and cross-validation.

Difference between Machine learning model and Algorithms


One of the most confusing questions among beginners is that are machine learning models, and algorithms are the same?
Because in various cases in machine learning and data science, these two terms are used interchangeably.

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.

Machine Learning ModelModel = Model Data + Prediction Algorithm


Next Topic
t

Here’s a detailed explanation of the concepts you mentioned, along with examples and
mathematical formulations for better understanding:

1. Predicting New Observations

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.

2. Supervised Learning Algorithms

Supervised learning involves learning a mapping f(X)→Yf(X) \to Y from labeled data (X,Y)
(X, Y).

Linear Regression

Linear regression is a supervised learning method for predicting a continuous output.

 Mathematical Model:

Y=β0+β1X1+β2X2+⋯+βnXn+ϵY = \beta_0 + \beta_1X_1 + \beta_2X_2 + \dots + \beta_nX_n +


\epsilon

Where:

o YY: Dependent variable (target).


o XiX_i: Independent variables (features).
o β0\beta_0: Intercept.
o βi\beta_i: Coefficients of features.
o ϵ\epsilon: Error term.
 Goal: Minimize the Mean Squared Error (MSE):

MSE=1n∑i=1n(Yi−Y^i)2MSE = \frac{1}{n} \sum_{i=1}^{n} \left( Y_i - \hat{Y}_i \right)^2

 Example: Predicting house prices based on:


o X1X_1: Size of the house.
o X2X_2: Number of bedrooms.
o X3X_3: Distance to the city center.

3. Unsupervised Learning Algorithms

Unsupervised learning identifies hidden patterns in data without labeled outputs.

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.

 Mathematical Objective: Minimize the sum of squared distances (inertia):

J=∑i=1k∑x∈Ci∥x−μi∥2J = \sum_{i=1}^{k} \sum_{x \in C_i} \| x - \mu_i \|^2

Where:

o CiC_i: Cluster ii.


o μi\mu_i: Centroid of cluster ii.

 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:

1. Agent: The decision-maker (e.g., a robot, software program).


2. Environment: The system with which the agent interacts.
3. State (SS): The current situation of the agent.
4. Action (AA): Choices available to the agent.
5. Reward (RR): Feedback received after an action.
6. Policy (π\pi): A mapping from states to actions.
7. Value Function (V(S)V(S)): Expected long-term reward for a state.

Types of RL Algorithms:

1. Value-Based:
o Example: Q-Learning.
o Goal: Learn the optimal action-value function: Q(s,a)=R+γmax⁡aQ(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:

 Self-driving cars (choosing driving actions).


 Game-playing agents (e.g., AlphaGo).
 Robotics (manipulation tasks).

Comparison of Machine Learning Types

Reinforcement
Aspect Supervised Learning Unsupervised Learning
Learning

Data Labeled Unlabeled Interaction-based

Predict outcomes for Maximize cumulative


Goal Discover hidden patterns
unseen data reward

Example Linear Regression,


K-Means, PCA Q-Learning, DQN
Algorithms Decision Trees

Fraud detection, Sales Customer segmentation,


Applications Robotics, Game playing
forecasting Anomaly detection
If you'd like further clarification or more examples, feel free to ask!

You might also like