Professional Documents
Culture Documents
1. Information Gain:
o Information gain is the measurement of
changes in entropy after the segmentation
of a dataset based on an attribute.
o It calculates how much information a
feature provides us about a class.
o According to the value of information gain,
we split the node and build the decision
tree.
o A decision tree algorithm always tries to
maximize the value of information gain,
and a node/attribute having the highest
information gain is split first. It can be
calculated using the below formula:
1. Information Gain= Entropy(S)- [(Weighted A
vg) *Entropy(each feature)
Entropy: Entropy is a metric to measure the
impurity in a given attribute. It specifies
randomness in data. Entropy can be calculated
as:
Entropy(s)= -P(yes)log2 P(yes)- P(no)
log2 P(no)
Where,
o S= Total number of samples
o P(yes)= probability of yes
o P(no)= probability of no
2. Gini Index:
o Gini index is a measure of impurity or
purity used while creating a decision tree
in the CART(Classification and Regression
Tree) algorithm.
o An attribute with the low Gini index should
be preferred as compared to the high Gini
index.
o It only creates binary splits, and the CART
algorithm uses the Gini index to create
binary splits.
o Gini index can be calculated using the
below formula:
Gini Index= 1- ∑jPj2
Pruning: Getting an Optimal
Decision tree
Pruning is a process of deleting the
unnecessary nodes from a tree in order to get
the optimal decision tree.
A too-large tree increases the risk of
overfitting, and a small tree may not capture
all the important features of the dataset.
Therefore, a technique that decreases the size
of the learning tree without reducing accuracy
is known as Pruning. There are mainly two
types of tree pruning technology used:
o Cost Complexity Pruning
o Reduced Error Pruning.
What Is a Hypothesis?
A hypothesis is an explanation for something.
It is a provisional idea, an educated guess that
requires some evaluation.
A good hypothesis is testable; it can be either
true or false.
In science, a hypothesis must be falsifiable,
meaning that there exists a test whose outcome
could mean that the hypothesis is not true. The
hypothesis must also be framed before the
outcome of the test is known.
A good hypothesis fits the evidence and can be
used to make predictions about new
observations or new situations.
The hypothesis that best fits the evidence and
can be used to make predictions is called a
theory, or is part of a theory.
● Hypothesis in Science: Provisional explanation
that fits the evidence and can be confirmed or
disproved.
What Is a Hypothesis in Statistics?
Much of statistics is concerned with the
relationship between observations.
Statistical hypothesis tests are techniques used
to calculate a critical value called an “effect.” The
critical value can then be interpreted in order to
determine how likely it is to observe the effect if
a relationship does not exist.
If the likelihood is very small, then it suggests
that the effect is probably real. If the likelihood is
large, then we may have observed a statistical
fluctuation, and the effect is probably not real.
For example, we may be interested in evaluating
the relationship between the means of two
samples, e.g. whether the samples were drawn
from the same distribution or not, whether there
is a difference between them.
One hypothesis is that there is no difference
between the population means, based on the
data samples.
This is a hypothesis of no effect and is called the
null hypothesis and we can use the statistical
hypothesis test to either reject this hypothesis, or
fail to reject (retain) it. We don’t say “accept”
because the outcome is probabilistic and could
still be wrong, just with a very low probability.
If the null hypothesis is rejected, then we assume
the alternative hypothesis that there exists some
difference between the means.
● Null Hypothesis (H0): Suggests no effect.
● Alternate Hypothesis (H1): Suggests some
effect.
Statistical hypothesis tests don’t comment on
the size of the effect, only the likelihood of the
presence or absence of the effect in the
population, based on the observed samples of
data.
● Logistic Regression
● K-Nearest Neighbours
● Kernel SVM
● Naïve Bayes
Regression:
Regression is a process of finding the correlations between
dependent and independent variables. It helps in predicting the
continuous variables such as prediction of Market Trends,
prediction of House prices, etc.
The task of the Regression algorithm is to find the mapping
function to map the input variable(x) to the continuous output
variable(y).
Example: Suppose we want to do weather forecasting, so for
this, we will use the Regression algorithm. In weather
prediction, the model is trained on the past data, and once the
training is completed, it can easily predict the weather for future
days.
Types of Regression Algorithm:
● Polynomial Regression
value.
input value (x) with the value(x) with the discrete output
variable(y).
Regression Algorithms Classification Algorithms are
data.
find the best fit line, which decision boundary, which can
Regression.
Artificial Neural Network Tutorial
Dendrites Inputs
Synapse Weights
Axon Output
Input Layer:
As the name suggests, it accepts inputs in several different formats provided by the
programmer.
Hidden Layer:
The hidden layer presents in-between input and output layers. It performs all the
calculations to find hidden features and patterns.
Output Layer:
The input goes through a series of transformations using the hidden layer, which
finally results in output that is conveyed using this layer.
The artificial neural network takes input and computes the weighted sum of the
inputs and includes a bias. This computation is represented in the form of a transfer
function.
Artificial neural networks have a numerical value that can perform more than one
task simultaneously.
Data that is used in traditional programming is stored on the whole network, not on a
database. The disappearance of a couple of pieces of data in one place doesn't
prevent the network from working.
After ANN training, the information may produce output even with inadequate data.
The loss of performance here relies upon the significance of missing data.
Extortion of one or more cells of ANN does not prohibit it from generating output,
and this feature makes the network fault-tolerance.
It is the most significant issue of ANN. When ANN produces a testing solution, it
does not provide insight concerning why and how. It decreases trust in the network.
Hardware dependence:
Artificial neural networks need processors with parallel processing power, as per
their structure. Therefore, the realization of the equipment is dependent.
ANNs can work with numerical data. Problems must be converted into numerical
values before being introduced to ANN. The presentation mechanism to be resolved
here will directly impact the performance of the network. It relies on the user's
abilities.
If the weighted sum is equal to zero, then bias is added to make the output non-zero
or something else to scale up to the system's response. Bias has the same input, and
weight equals to 1. Here the total of weighted inputs can be in the range of 0 to
positive infinity. Here, to keep the response in the limits of the desired value, a certain
maximum value is benchmarked, and the total of weighted inputs is passed through
the activation function.
The activation function refers to the set of transfer functions used to achieve the
desired output. There is a different kind of the activation function, but primarily either
linear or non-linear sets of functions. Some of the commonly used sets of activation
functions are the Binary, linear, and Tan hyperbolic sigmoidal activation functions.
Let us take a look at each of them in details:
Binary:
In the binary activation function, the output is either a one or a 0. Here, to accomplish
this, there is a threshold value set up. If the net weighted input of neurons is more
than 1, then the final output of the activation function is returned as one or else the
output is returned as 0.
Types of Artificial Neural Network:
There are various types of Artificial Neural Networks (ANN) depending upon the
human brain neuron and network functions, an artificial neural network similarly
performs tasks. The majority of the artificial neural networks will have some
similarities with a more complex biological partner and are very effective at their
expected tasks. For example, segmentation or classification.
Feedback ANN:
In this type of ANN, the output returns into the network to accomplish the
best-evolved results internally. As per the University of Massachusetts, Lowell
Centre for Atmospheric Research. The feedback networks feed information back into
itself and are well suited to solve optimization issues. The Internal system error
corrections utilize feedback ANNs.
Feed-Forward ANN:
A feed-forward network is a basic neural network comprising of an input layer, an
output layer, and at least one layer of a neuron. Through assessment of its output by
reviewing its input, the intensity of the network can be noticed based on group
behavior of the associated neurons, and the output is decided. The primary
advantage of this network is that it figures out how to evaluate and recognize input
patterns.
Machine learning can be summarized as learning a function (f) that maps input variables
(X) to output variables (Y).
Y = f(x)
The form of the function is unknown, so our job as machine learning practitioners is to
evaluate different machine learning algorithms and see which is better at approximating
the underlying function.
Different algorithms make different assumptions or biases about the form of the
function and how it can be learned.
Assumptions can greatly simplify the learning process, but can also limit what can be
learned. Algorithms that simplify the function to a known form are called parametric
machine learning algorithms.
A learning model that summarizes data with a set of parameters of fixed size
(independent of the number of training examples) is called a parametric model. No
matter how much data you throw at a parametric model, it won’t change its mind about
how many parameters it needs.
An easy to understand functional form for the mapping function is a line, as is used in
linear regression:
b0 + b1*x1 + b2*x2 = 0
Where b0, b1 and b2 are the coefficients of the line that control the intercept and slope,
and x1 and x2 are two input variables.
Assuming the functional form of a line greatly simplifies the learning process. Now, all
we need to do is estimate the coefficients of the line equation and we have a predictive
model for the problem.
Often the assumed functional form is a linear combination of the input variables and as
such parametric machine learning algorithms are often also called “linear machine
learning algorithms“.
Algorithms that do not make strong assumptions about the form of the mapping
function are called nonparametric machine learning algorithms. By not making
assumptions, they are free to learn any functional form from the training data.
Nonparametric methods seek to best fit the training data in constructing the mapping
function, whilst maintaining some ability to generalize to unseen data. As such, they are
able to fit a large number of functional forms.
● k-Nearest Neighbors
● Decision Trees like CART and C4.5
● Support Vector Machines
● More data: Require a lot more training data to estimate the mapping function.
● Slower: A lot slower to train as they often have far more parameters to train.
● Overfitting: More of a risk to overfit the training data and it is harder to explain
why specific predictions are made.
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. This best decision boundary is called
a hyperplane.
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:
Example: SVM can be understood with the example that we have used in the KNN
classifier. Suppose we see a strange cat that also has some features of dogs, so if
we want a model that can accurately identify whether it is a cat or dog, so such a
model can be created by using the SVM algorithm. We will first train our model with
lots of images of cats and dogs so that it can learn about different features of cats
and dogs, and then we test it with this strange creature. So as support vector creates
a decision boundary between these two data (cat and dog) and choose extreme
cases (support vectors), it will see the extreme case of cat and dog. On the basis of
the support vectors, it will classify it as a cat. Consider the below diagram:
00:00/06:36
SVM algorithm can be used for Face detection, image classification, text
categorization, etc.
Types of SVM
● Linear SVM: Linear SVM is used for linearly separable data, which means if a
dataset can be classified into two classes by using a single straight line, then
such data is termed as linearly separable data, and classifier is used called as
Linear SVM classifier.
We always create a hyperplane that has a maximum margin, which means the
maximum distance between the data points.
Support Vectors:
The data points or vectors that are the closest to the hyperplane and which affect the
position of the hyperplane are termed as Support Vector. Since these vectors
support the hyperplane, hence called a Support vector.
The working of the SVM algorithm can be understood by using an example. Suppose
we have a dataset that has two tags (green and blue), and the dataset has two
features x1 and x2. We want a classifier that can classify the pair(x1, x2) of
coordinates in either green or blue. Consider the below image:
So as it is 2-d space so by just using a straight line, we can easily separate these two
classes. But there can be multiple lines that can separate these classes. Consider
the below image:
Hence, the SVM algorithm helps to find the best line or decision boundary; this best
boundary or region is called as a hyperplane. SVM algorithm finds the closest point
of the lines from both the classes. These points are called support vectors. The
distance between the vectors and the hyperplane is called as margin. And the goal of
SVM is to maximize this margin. The hyperplane with maximum margin is called the
optimal hyperplane.
Non-Linear SVM:
If data is linearly arranged, then we can separate it by using a straight line, but for
non-linear data, we cannot draw a single straight line. Consider the below image:
So to separate these data points, we need to add one more dimension. For linear
data, we have used two dimensions x and y, so for non-linear data, we will add a third
dimension z. It can be calculated as:
z=x2 +y2
By adding the third dimension, the sample space will become as below image:
So now, SVM will divide the datasets into classes in the following way. Consider the
below image:
Since we are in 3-d Space, hence it is looking like a plane parallel to the x-axis. If we
convert it in 2d space with z=1, then it will become as:
● Majority Vote
● Bagging and Random Forest
● Randomness Injection
● Feature-Selection Ensembles
● Error-Correcting Output Coding
5.
Random Forest:
Random Forest is an extension over bagging. Each classifier in the
ensemble is a decision tree classifier and is generated using a
random selection of attributes at each node to determine the split.
During classification, each tree votes and the most popular class is
returned.
Implementation steps of Random Forest –
1. Multiple subsets are created from the original data set,
selecting observations with replacement.
2. A subset of features is selected randomly and whichever
feature gives the best split is used to split the node iteratively.
3. The tree is grown to the largest.
4. Repeat the above steps and prediction is given based on the
aggregation of predictions from n number of trees.