Supervised Learning in Machine Learning
Supervised Learning in Machine Learning
Supervised Learning, learning a Class from Examples, Noise, Learning Multiple Classes,
Regression, Model Selection and Generalization, Classification, Decision trees – Support vector
machines -Neural networks (Gradient Descent and Back Propagation), Naïve Bayes Algorithm,
Linear Regression and Logistic Regression, Random Forest, Ensemble Learning
Given a training set of labeled examples (positive and negative) to learn a classifier that can be
used to predict unseen examples, or to understand the data.
• Input representation: To decide what attributes (features) to use to describe the input
patterns (examples, instances). This implies ignoring other attributes as irrelevant.
• Hypothesis (model) class H: the set of classifier functions. Ideally, the true class
distribution C can be represented by a function in H (exactly, or with a small error).
CS1701A Machine Learning Department of CSE- SAEC Unit II 1
Input representation
• Assigning a class label to an unknown instance from instances of known assignments of labels.
• An object will have large number of features which may contribute to the assignment of the
labels.
• Only important features as inputs for assigning the class labels.
• These features are referred to as the “input features” /”input representation” for the problem.
Example Consider the problem of assigning the label “family car” or “not family car” to cars. Let
us assume that the features that separate a family car from other cars are the price and engine
power. These attributes or features constitute the input representation for the problem. While
deciding on this input representation, we are ignoring various other attributes like seating capacity
or colour as irrelevant.
Data in Table with hollow dots representing positive examples and solid dots representing negative
examples
Version space
Consider a binary classification problem. Let D be a set of training examples and H a hypothesis
space for the problem. The version space for the problem with respect to the set D and the space
H is the set of hypotheses from H consistent with D; that is, it is the set
● Noise distorts data. When there is noise in data, learning problems may not produce
accurate results.
● Also, simple hypotheses may not be sufficient to explain the data and so complicated
hypotheses may have to be formulated.
● This leads to the use of additional computing resources and the needless wastage of such
resources.
For example, in a binary classification problem with two variables, when there is noise, there may
not be a simple boundary between the positive and negative instances and to separate them.
The effect of these neglected attributes is thus modeled as a random component and is
included in “noise.”
A rectangle can be defined by four numbers, but to define a more complicated shape one needs a
more complex model with a much larger number of parameters. With a complex model, one can
make a perfect fit to the data and attain zero error; see the wiggly shape in figure . Another
possibility is to keep the model simple and allow some error; see the rectangle in figure.
Using the simple rectangle (unless its training error is much bigger) makes more sense
because of the following:
1. It is a simple model to use. It is easy to check whether a point is inside or outside a rectangle
and we can easily check, for a future data instance, whether it is a positive or a negative instance.
2. It is a simple model to train and has fewer parameters. It is easier to find the corner values
of a rectangle than the control points of an arbitrary shape. With a small training set when the
training instances differ a little bit, we expect the simpler model to change less than a complex
model: A simple model is thus said to have less variance. On the other hand, a too simple model
assumes more, is more rigid, and may fail if indeed the underlying class is not that simple: A
simpler model has more bias. Finding the optimal model corresponds to minimizing both the bias
and the variance.
3. It is a simple model to explain. A rectangle simply corresponds to defining intervals on the
two attributes. By learning a simple model, we can extract information from the raw data given in
the training set.
4. If indeed there is mislabeling or noise in input and the actual class is really a simple model
like the rectangle, then the simple rectangle, because it has less variance and is less affected by
single instances, will be a better discriminator than the wiggly shape, although the simple one may
make slightly more errors on the training set.
Given comparable empirical error, we say that a simple (but not too simple) model would
generalize better than a complex model.
This principle Occam’s razor is known as Occam’s razor, which states that simpler
explanations are more plausible and any unnecessary complexity should be shaved off.
For a given x, ideally only one of hi(x) is 1 and then we assign the class Ci to x. But, when no, or,
two or more, hi(x) is 1, we cannot choose a class. In such a case, we say that the classifier rejects
such cases.
b) “One-against-one” method
In the one-against-one (OAO) (also called one-vs-one (OVO)) strategy, a classifier is constructed
for each pair of classes. If there are K different class labels, a total of K(K – 1)/2 classifiers are
constructed. An unknown instance is classified with the class getting the most votes. Ties are
broken arbitrarily.
For example, let there be three classes, A, B and C. In the OVO method we construct 3(3 − 1)/2 =
3 binary classifiers. Now, if any x is to be classified, we apply each of the three classifiers to x.
Let the three classifiers assign the classes A, B, B respectively to x. Since a label to x is assigned
by the majority voting, in this example, we assign the class label of B to x
In our example of learning a family car, we have positive examples belonging to the class family
car and the negative examples belonging to all other cars. This is a two-class problem. In the
general case, we have K
• With K classes, we can code the label as an integer y = k ∈ {1, . . . ,K}, or as a one-of-K binary
vector y = (y1, . . . , yK)T ∈ {0, 1}K (containing a single 1 in position k).
• One approach for K-class classification: consider it as K two-class classification problems, and
minimize the total empirical error:
CS1701A Machine Learning Department of CSE- SAEC Unit II 8
where yn is coded as one-of-K and hk is the two-class classifier for problem k, i.e., hk(x) ∈
{0, 1}.
• Ideally, for a given pattern x only one hk(x) is one. When no, or more than one, hk(x) is one
then the classifier is in doubt and may reject the pattern.
Figure There are three classes: family car, sports car, and luxury sedan. There are three hypotheses induced,
each one covering the instances of one class and leaving outside the instances of the other two classes. ‘?’ are
reject regions where no, or more than one, class is chosen.
In our example of learning a family car, we used only one hypothesis and only modeled the positive
examples. Any negative example outside is not a family car. Alternatively, sometimes we may
prefer to build two hypotheses, one for the positive and the other for the negative instances. This
assumes a structure also for the negative instances that can be covered by another hypothesis.
Separating family cars from sports cars is such a problem; each class has a structure of its own.
The advantage is that if the input is a luxury sedan, we can have both hypotheses decide negative
and reject the input.
If in a dataset, we expect to have all classes with similar distribution— shapes in the input space—
then the same hypothesis class can be used for all classes. For example, in a handwritten digit
recognition dataset, we would expect all digits to have similar distributions. But in a medical
diagnosis dataset, for example, where we have two classes for sick and healthy people, we may
have completely different distributions for the two classes; there may be multiple ways for a person
to be sick, reflected differently in the inputs: All healthy people are alike; each sick person is sick
in his or her own way.
A regression problem is the problem of determining a relation between one or more independent
variables and an output variable which is a real continuous variable, given a set of observed values
of the set of independent variables and the corresponding values of the output variable.
Examples
1. Let us say we want to have a system that can predict the price of a used car. Inputs are the car
attributes such as brand, year, engine capacity, mileage, and other information that we
believe affect a car’s worth. The output is the price of the car.
2. Consider the navigation of a mobile robot, say an autonomous car. The output is the angle by
which the steering wheel should be turned at each time, to advance without hitting obstacles
and deviating from the route. Inputs are provided by sensors on the car like a video camera,
GPS, and so forth.
3. In finance, the capital asset pricing model uses regression for analyzing and quantifying the
systematic risk of an investment.
4. In economics, regression is the predominant empirical tool. For example, it is used to predict
consumption spending, inventory investment, purchases of a country’s exports, spending on
imports, labor demand, and labor supply.
Different regression models
The different regression models are defined based on type of functions used to represent the
relation between the dependent variable y and the independent variables.
1. Simple linear regression
Assume that there is only one independent variable x. If the relation between x and y is modeled
by the relation
y = a + bx
then we have a simple linear regression.
2. Multiple regression
Let there be more than one independent variable, say x1, x2, : : :, xn, and let the relation between y
and the independent variables be modeled as
Model selection
• There is no universally accepted definition of the term “model”. It may be understood as some
mathematical expression or equation, or some mathematical structures such as graphs and
trees, or a division of sets into disjoint subsets, or a set of logical “if : : : then : : : else : : :”
rules, or some such thing.
• In order to formulate a hypothesis for a problem, we have to choose some model and the term
“model selection” has been used to refer to the process of choosing a model.
• However, the term has been used to indicate several things. In some contexts it has been used
to indicate the process of choosing one particular approach from among several different
approaches. This may be choosing an appropriate algorithms from a selection of possible
algorithms, or choosing the sets of features to be used for input, or choosing initial values for
certain parameters.
• Sometimes “model selection” refers to the process of picking a particular mathematical model
from among different mathematical models which all purport to describe the same data set. It
has also been described as the process of choosing the right inductive bias.
Inductive bias
In a learning problem we only have the data. But data by itself is not sufficient to find the solution.
We should make some extra assumptions to have a solution with the data we have. The set of
assumptions we make to have learning possible is called the inductive bias of the learning
algorithm.
One way we introduce inductive bias is when we assume a hypothesis class.
Examples
● Decision nodes are typically impure, or a mixture of both classes of the target variable
● Pure nodes are those that have one class — hence the term pure.
Variable selection criterion
Variables are selected on a complex statistical criterion which is applied at each decision node.
Now, variable selection criterion in Decision Trees can be done via the following approaches:
1. Entropy
2. Information Gain
3. Gini Index
1. Entropy
● Entropy is a measure of the impurity in a collection of training examples
● Entropy is the measure of the degree of randomness or uncertainty in the dataset.
● In the case of classifications it measures the randomness based on the distribution of class
labels in the dataset.
2. Information Gain
● Information gain is a measure of the effectiveness of an attribute in classifying the training
data.
How it works:
1. Calculate Information Gain: For each attribute, calculate the information gain, which
measures the decrease in entropy (uncertainty) after splitting the data based on that
attribute.
2. Select Best Attribute: Choose the attribute with the highest information gain as the root
node.
3. Create Child Nodes: Split the dataset into subsets based on the values of the selected
attribute.
4. Recursively Apply: Repeat steps 1-3 for each subset until a pure node (all instances belong
to the same class) is reached or there are no more attributes to split on.
How it works:
1. Calculate Splitting Criterion: For each attribute, calculate the Gini impurity (or squared
error for regression) for all possible splits.
2. Select Best Split: Choose the split that minimizes the impurity (or squared error).
3. Create Child Nodes: Split the dataset into two subsets based on the selected split.
4. Recursively Apply: Repeat steps 1-3 for each subset until a stopping criterion is met (e.g.,
minimum number of instances in a node).
● Support Vector Machine (later generalized under the name kernel machine) is a relatively
new classification method for both linear and nonlinear data
● It uses a nonlinear mapping to transform the original training data into a higher dimension
● With the new dimension, it searches for the linear optimal separating hyperplane(i.e., “decision
boundary”)
● With an appropriate nonlinear mapping to a sufficiently high dimension, data from two classes
can always be separated by a hyperplane
● SVM finds this hyperplane using support vectors (“essential” training tuples) and
margins(defined by the support vectors)
● Linear classifiers: logistic regression, Gaussian classes with common covariance, now linear
SVMs.
Features: training can be slow but accuracy is high owing to their ability to model complex
nonlinear decision boundaries (margin maximization)
• Used both for classification and prediction
• Applications:
● The goal of the SVM algorithm is to create the best line or decision boundary that can
segregate n-dimensional space into classes so that we can easily put the new data point in
the correct category in the future.
● SVM chooses the extreme points/vectors that help in creating the hyperplane.
● These extreme cases are called as support vectors, and hence algorithm is termed as
Support Vector Machine
Consider the below diagram in which there are two different categories that are classified using a
decision boundary or hyperplane:
Linear Classifiers
Consider a two dimensional dataset with two classes
Where
● Soft margin is a technique used in Support Vector Machine (SVM) classification that
allows for some misclassification of data points in order to achieve a wider margin and a
more flexible decision boundary.
● In traditional SVM classification with a hard margin, the goal is to find a hyperplane that
completely separates the two classes of data with no misclassification. However, in real-
world datasets, this is often not possible due to noise, outliers, or other factors that make
the data non-separable.
● The objective is to find the optimal hyperplane that maximizes the margin while also
minimizing the amount of misclassification.
● Cross Validation is used to determine the best soft margin.
1. Kernel function: In SVM, a kernel function is used to transform the input data into a
higher dimensional space where it can be more easily separated. Popular kernel functions
include linear, polynomial, and radial basis function (RBF) kernels.
2. Kernel trick: Kernel trick is a technique used in machine learning, specifically in Support
Vector Machine (SVM) algorithms, to transform a low-dimensional input space to a higher
dimensional feature space without actually computing the coordinates of the data in the
higher dimensional space.
3. By using the kernel function to compute the dot product, the data points are effectively
mapped to a higher dimensional space without explicitly computing their coordinates.
/Non-linear SVMs
• Datasets that are linearly separable with some noise work out great:
● The study of artificial neural networks (ANNs) has been inspired in part by the observation
that biological learning systems are built of very complex webs of interconnected neurons.
● Artificial neural networks (ANNs) provide a general, practical method for learning real-valued,
discrete-valued, and vector-valued functions from examples.
● ANN learning is robust to errors in the training data and has been successfully applied to
problems such as interpreting visual scenes, speech recognition, and learning robot control
strategies.
● A neural network model is trained using the stochastic gradient descent optimization
algorithm and weights are updated using the backpropagation of error algorithm
Types of Neural Networks
There are many different types of neural networks and each of the neural network types is specific
to certain business scenarios and data patterns.
One type of ANN system is based on a unit called a perceptron. A perceptron takes a vector of
real-valued inputs, calculates a linear combination of these inputs, then outputs a 1 if the result is
greater than some threshold and -1 otherwise.
● Given inputs xl through xn , the output o(x1, . . . , xn) computed by the perceptron is:
Figure: Perceptron
Perceptron - Learning
● The space H of candidate hypotheses considered in perceptron learning is the set of all
possible real-valued weight vectors
Representational Power of Perceptrons
● Some sets of positive and negative examples cannot be separated by any hyperplane. Those
that can be separated are called linearly separable sets of examples.
✔ Each pass through all of the training examples is called one epoch
• Weights are modified at each step according to perceptron training rule which revises the
weight wi associated with input xi according to the rule
where
● If the output is incorrect (t≠ o) the weights wi are changed such that the output of the
perceptron for the new weights is closer to t.
● It's an iterative process that helps minimize the cost function by adjusting the network's weights
and biases.
● Use gradient descent to learn the weights
The operations of the Backpropagation neural networks can be divided into two steps:
Feedforward and Backpropagation.
o In the feedforward step, an input pattern is applied to the input layer and its effect propagates,
layer by layer, through the network until an output is produced.
o The network's actual output value is then compared to the expected output, and an error signal
is computed for each of the output nodes.
o Since all the hidden nodes have, to some degree, contributed to the errors evident in the output
layer, the output error signals are transmitted backwards from the output layer to each node in
the hidden layer that immediately contributed to the output layer.
o This process is then repeated, layer by layer, until each node in the network has received an
error signal that describes its relative contribution to the overall error.
o Once the error signal for each node has been determined, the errors are then used by the nodes
to update the values for each connection weights until the network converges to a state that
allows all the training patterns to be encoded.
o The Backpropagation algorithm looks for the minimum value of the error function in weight
space using a technique called the delta rule or gradient descent. The weights that minimize
the error function is then considered to be a solution to the learning problem.
Back-propagation: Loop until convergence:
Key Components
● Error Function: Measures the difference between the predicted output and the actual
target.
● Gradient Descent: Optimization algorithm used to update weights and biases.
● Chain Rule: Used to calculate gradients efficiently.
● Activation Functions: Introduce non-linearity into the network.
Activation Functions
Activation functions are an integral building block of neural networks that enable them to learn
complex patterns in data. They transform the input signal of a node in a neural network into an
output signal that is then passed on to the next layer . Types are
Sigmoid
Tanh
ReLU (Rectified Linear Unit)
Example
Gradient descent is the most popular optimization technique for feedforward neural networks. The
term “gradient” refers to the quantity change of output obtained from a neural network when the
inputs change a little. Technically, it measures the updated weights concerning the change in error.
The gradient can also be defined as the slope of a function. The higher the angle, the steeper the
slope and the faster a model can learn.
Although the perceptron rule finds a successful weight vector when the training examples are
linearly separable, it can fail to converge if the examples are not linearly separable. A second
training rule, called the delta rule, is designed to overcome this difficulty. If the training examples
are not linearly separable, the delta rule converges toward a best-fit approximation to the target
concept.
The key idea behind the delta rule is to use gradient descent to search the hypothesis space of
possible weight vectors to find the weights that best fit the training examples. This rule is important
because gradient descent provides the basis for the BACKPROPAGATION algorithm, which can
learn networks with many interconnected units. It is also important because gradient descent can
serve as the basis for learning algorithms that must search through hypothesis spaces containing
many different types of continuously parameterized hypotheses
• The perceptron rule finds a successful weight vector when the training examples are linearly
separable, it can fail to converge if the examples are not linearly separable.
• The delta rule overcomes this difficulty.
• If the training examples are not linearly separable, the delta rule converges toward a best-fit
approximation to the target concept.
• The key idea behind the delta rule is to use gradient descent to search the hypothesis space
of possible weight vectors to find the weights that best fit the training examples.
• The delta rule is important because gradient descent provides the basis for the
BACKPROPAGATION Algorithm, which can learn networks with many interconnected
units.
• The gradient descent can serve as the basis for learning algorithms that must search through
hypothesis spaces containing many different types of continuously parameterized hypotheses
● Conditional probability is based on finding the probability that something will happen,
given that something else has already happened.
● The task of the algorithm then is to look at the evidence and to determine the likelihood of a
specific class and assign a label accordingly to each entity.
● Bayes theorem provides a way to calculate the probability of a hypothesis based on its prior
probability, the probabilities of observing various data given the hypothesis, and the observed
data itself.
Naïve Bayes is an example of a probabilistic classifier. We can do this using the Bayes rule
defined as
Bayes theorem provides a way to calculate the posterior probability P(A|B), from the prior
probability P(A), together with P(B) and P(B|A).
1. The importance of the result is that it helps us to “invert” conditional probabilities, that is, to
express the conditional probability P(A|B) in terms of the conditional probability P(B|A).
2. The following terminology is used in this context:
● P(A) is called the prior probability of proposition and P(B) is called the prior probability
CS1701A Machine Learning Department of CSE- SAEC Unit II 36
of evidence.
1. Linear Regression:
● Linear regression is a statistical regression method which is used for predictive analysis.
● It is one of the very simple and easy algorithms which works on regression and shows the
relationship between the continuous variables.
● Linear regression shows the linear relationship between the independent variable (X-axis)
and the dependent variable (Y-axis), hence called linear regression.
Types of Linear Regression
Linear regression can be further divided into two types of the algorithm:
Y= aX+b
Here, Y = dependent variables (target variables),
X= Independent variables (predictor variables),
a and b are the linear coefficients
● Salary forecasting
Example: Find the linear regression equation for the given data:
X Y
3 8
9 6
5 4
3 2
x y x2 xy
3 8 9 24
9 6 81 54
5 4 25 20
3 2 9 6
● The different values for weights or coefficient of lines (a0, a1) gives the different line of
regression, and the cost function is used to estimate the values of the coefficient for the best
fit line.
● Cost function optimizes the regression coefficients or weights. It measures how a linear
regression model is performing.
● We can use the cost function to find the accuracy of the mapping function, which maps the
input variable to the output variable. This mapping function is also known as Hypothesis
function.
For Linear Regression, we use the Mean Squared Error (MSE) cost function, which is the
average of squared error occurred between the predicted values and actual values. It can be written
as:
2. Logistic Regression:
● Logistic regression is another supervised learning algorithm which is used to solve the
classification problems. In classification problems, we have dependent variables in a binary
or discrete format such as 0 or 1.
● Logistic regression algorithm works with the categorical variable such as 0 or 1, Yes or No,
True or False, Spam or not spam, etc.
● Logistic regression is a type of regression, but it is different from the linear regression
algorithm in the term how they are used.
● Logistic regression uses sigmoid function or logistic function which is a complex cost
function. This sigmoid function is used to model the data in logistic regression. The function
can be represented as:
● Binary(0/1, pass/fail)
● A random forest is an ensemble learning method where multiple decision trees are constructed
and then they are merged to get a more accurate prediction.
● Ideally, we consider each vote from every tree and chose the most voted classification
(Majority-Voting).
● Random Forest follow the same bagging process as the decision trees but each time a split is
to be performed, the search for the split variable is limited to a random subset of m of the p
attributes (variables or features) aka Split-Attribute Randomization :
✔ classification trees: m = √p
Algorithm
Here is an outline of the random forest algorithm.
1. The random forests algorithm generates many classification trees. Each tree is generated
as follows:
• Ensemble Learning is a technique that create multiple models and then combine them to
produce improved results.
• Ensemble learning usually produces more accurate solutions than a single model would.
• Ensemble learning methods is applied to regression as well as classification.
✔ Ensemble learning for regression creates multiple repressors i.e. multiple regression
models such as linear, polynomial, etc.
✔ remaining 1/3 of the observations are referred to as the out-of-bag (OOB) observations
• Each individual tree has high variance, but low bias, averaging these trees reduces the
variance
• Reduce overfitting; reduce bias; break the bias-variance trade-off
CS1701A Machine Learning Department of CSE- SAEC Unit II 49
Vanilla Bagging
Vanilla Bagging is widely used in real-world applications including credit risk assessment, fraud
detection, stock price prediction etc.
Algorithm
• In Vanilla Bagging, we use bootstrap method (randomly choosing an element with replacement)
to make subset datasets of equal length as the initial dataset.
• Even though the number of elements in subsets are equal to the number of elements in the
original dataset, they are not the same dataset as the draw has been done with replacements.
• The number of subsets, N, is a hyperparameter.
2. Boosting
Boosting is an ensemble learning method that combines a set of weak learners into a strong
learner to minimize training errors.
In boosting, a random sample of data is chosen, fitted with a model, and then sequentially
trained. In other words, each model aims to make up for the shortcomings of the one before
it.
Intuitively, we do not have a super learner, but many bad learners. These bad learners are
combined to obtain a strong learner with lower bias.
So, Boosting is used to shift the models from high bias −→ low bias
Steps in Boosting:
– Use the training set to train a simple predictor.
– Re-weight the training examples, putting more weight on examples that were not properly
classified in the previous predictor.
– Repeat n times.
– Combine the simple hypotheses into a single, accurate predictor
Bagging Vs Boosting
The Random Forest method utilizes ensemble learning by constructing multiple decision trees and combining their outputs through majority voting for classification or averaging for regression. This approach increases prediction accuracy and reduces overfitting compared to single decision trees by aggregating diverse models built on random subsets of data and features, ensuring a robust overall model .
The Naïve Bayes algorithm applies conditional probability to classification by calculating the likelihood of a class, given prior class probability and observed data feature probabilities. As a probabilistic classifier, it assigns labels based on Bayes' theorem, which combines prior probability with likelihood to compute posterior probability for making informed predictions .
Logistic regression manages binary classification problems by using the sigmoid function, which converts the linear regression output into a probability ranging between 0 and 1. This function allows logistic regression to predict whether a given input falls into one of two categories by setting a decision threshold that determines the output classification, such as 0 or 1, True or False .
Gradient descent optimizes neural networks by iteratively updating weights to minimize the cost function, which measures prediction error. The delta rule uses gradient descent to achieve this by approximating the optimal weights, especially when training examples are not linearly separable. It provides the basis for the backpropagation algorithm, essential for training complex neural networks with many interconnected layers .
In classification tasks, decision trees predict class labels by associating leaves with class labels and branches with feature conjunctions. In contrast, regression trees predict continuous values by using paths in the tree to guide the prediction of numerical outputs. The structure of decision trees remains the same for both types, consisting of decision nodes and leaves, but their target variable determines the specific type of tree used .
The Delta rule addresses the challenge of non-convergence in neural network training when examples are not linearly separable. It ensures convergence toward a best-fit weight approximation through gradient descent, vital for backpropagation. Backpropagation uses this gradient to adjust weights in network layers by propagating errors backward, crucial for learning complex patterns in non-linear datasets .
Backpropagation serves as the mechanism for calculating gradients in neural networks and updating weights by propagating errors backward through the network layers. While gradient descent is the overarching optimization process employed to find the cost function minimum, backpropagation specifically computes the gradient required for this process by differentiating how cost changes with respect to each weight, ensuring efficient parameter adjustment .
Cross-validation helps assess the generalization ability of machine learning models by dividing the original dataset into two parts: one for training and another as a validation set. These two sets simulate unseen data, allowing for evaluation of the model's inductive bias and generalization to new data. The hypothesis that performs best on the validation set is considered the one with the best inductive bias .
Cross-validation offers the benefit of providing a more reliable estimate of a model's performance by repeatedly splitting data into training and validation sets. This repeated analysis ensures that the model generalizes well to unseen data by thoroughly testing its inductive bias. However, cross-validation can be computationally intensive, especially for large datasets, and may not fully mimic real-world variations if the underlying data lacks representativeness .
Activation functions introduce non-linearity into neural networks, allowing them to learn complex patterns by transforming node input signals into output signals that are propagated to subsequent layers. The main types include the sigmoid function, which maps inputs to an output range between 0 and 1, the hyperbolic tangent (Tanh) function, and the Rectified Linear Unit (ReLU), which allows activations only above zero, enabling faster convergence .