Transcripts
1. Introduction To Course: Going to discuss
about the algorithms present in missing learning. So the algorithms like linear regression,
logistic regression. This is entry classifier,
random forest classifier, K and an algorithm, K means clustering, support
or missing algorithm. This course is very, very useful for those students
who are trying to learn missing learning
and data science with Python for
their first time. For that only, I have created this course
for those students. So let's get started.
2. Class 1 : Linear Regression: Welcome, everyone.
In today's class, we are going to
discuss about our first algorithm in
missin learning. So our first algorithm
will be linear regresson. So linear regresson is one of the type of supervised
mien learning. So the main concept of linear
regression is nothing, but it finds the
linear relationship between dependent variable and
then independent variable. For example, we have to see
the relationship between salary and so work will be considered as
independent variable. Salary will be considered
as dependent variable. Based on the work, our
salary will be increased. So based on the work, our salary also decreased. So work can be considered
as independent variable, and then salary will be
considered as dependent variable. So the concept of linear regression is
nothing but we have to find the relationship between
dependent variable and then independent variable. So you can see the graph, so you can see the X axis will be the
independent variable, and then Y axis will be
the dependent variable. After that, we have to find
the line of regresson. So line of regresson is
nothing but separation of line between the
independent variable and then dependent variable. So these are all the points
of the dependent variable. And these are all the points
of our independent variable. So this lines separates our dependent variable and
then independent variable. So that is line of regresson. So in linear regresson
there are two types. So the first one will be
simple linear regression. So simple linear
regression is nothing but only one dependent variable and then only one
independent variable. For example, we can
see the salary worth. It will be considered
as the example for simple linear regresson. So this is the example graph for simple linear regression. Xaxis will be the
independent variable, and then Yaxs will be
the dependent variable. So this line separates the independent variable and
then dependent variable. And then second type will be
multiple linear regresson. So multiple linear
regresson is nothing but one or more independent variable will predicts the value
of dependent variable. So you can see the example
for multiple linear regresen. So you can see there are a
lot of line of regressen which separates the
independent variable and then dependent variable. For finding the
line of regression, we are going to need the
help of slope pun intercept. For the slope intercept, you have to remember
the formula. Y equal MX plus B or beta
naught plus beta one nu X, Y is the dependent variable? X is the independent variable. So X will be the
independent variable, beta naught will be the intercept and beta
one will be the slope. So you can see the graph for the intercept and then slope. So you can see the graph. So X axis will be the
independent variable, and then Vyxls will be
the dependent variable. So this is the line
of recursen which separates the
independent variable and then dependent variable. So the formula will be
teta one plus teta two X. That is MX plus B. So then you have to find observed value and
then predicted value. So based on the
line of regression, you have to find
the predicted value and then observed value. So distance between
the predicted value, absurd value will
be random error. So there are three terms used. First one will be the absurd
value observed value, and then second one will
be the predicted value. And then distance between
the observed value and then predicted value
will be random error. So the slope and intrastep can be used for finding
the line of regressen. So line of regresen is
used for separating the dependent variable and
then independent variable. So after that, we are
going to discuss about how to find the best line of recorscen which separates
the dependent variable and then independent variable. For that, we are going to use the concept mean squired error. For the mean squired error, you have to remember
the formula. So the formula will be
one by N, summation, I equal to 12n and then Y minus AX plus A
naught whole square. So N will be the total
number of observation. Y will be the actual value, and then A one X plus A nut
will be the predicted value. So the predicted value will
be A one X plus A nut, and then Y will be
the observed value. So by using the mean
squared error method, we can find the
line of regression. So line of regression plays an important role in
the linear regression. So after that, we have to find the accuracy and precision
of our linear regreson. For finding the
model performance, we are going to use the
formula R squared method. So formula for R
square is nothing but explained variation divided
by total variation. So R squared is very, very useful for finding the performance of
our linear recurson. So it shows the strength
of our relationship between dependent variable and
then independent variable. After that, high
value of R determines the less difference between predicted value and
then actual value. So it represents good model. So our value of R will be large. If the value of R will be large, our model is very well trained. So value so R squared
value ranges 0-1. So R square is very, very useful for finding
the model performance. So higher the value of R, our model will be
higher the performance. At last, we're going
to discuss about the disadvantages of
linear regression. So the first
disadvantage will be so linear regression cannot
be used for complex problems. So that is we cannot use linear regression
for larger data set. We can only use for
smaller dataset. And then second
disadvantage will be sensitive to outliers. Outliers is nothing but
unwanted value in our dataset. So outliers decrease
our accuracy and precision in our model. So these are all the disadvantages
of linear regresson. So linear regresson is nothing, but we are going to
find the line of regresson using the formula
Y equality mt plus B. So line of regresson separates the dependent variable and
then independent variable.
3. Class 2 : Logistic Regression: Welcome everyone.
In today's class, we are going to discuss
about logistic rigors and algorithm in
machine learning. So logistic regresson is one of the type of supervised
learning algorithm. So in the previous class, we discussed about linear
regress and algorithm. So in linear regress and
we are going to need the help of slope intra for finding the line of
regresson which separates the independent variable and
then dependent variable. But in the case of
logistic regresson, we are going to
create the graph in the form of sigmoid function. So in the right hand side, you can see the example graph
for logistic regresson. So in the example of
logistic regresson graph, you can see the Apd graph. So that is sigmoid
function graph. So for the sigmoid function, there will be only two
output are possible, whether it can be zero or one. So if the S graph comes to zero, the output of logistic
regressen will be zero. If the SSAP graph goes to one, our output of logistic
regressent will be one. So there are two outputs are possible in
logistic regressent whether it can be zero or one
or true or false or or no. So our output will
be two values, whether it can be zero or one. So logistic regressen can be only possible for
classification problems. So after that, we are
going to discuss about the types of
logistic regurescen. So the first one will
be the binomial. So in binomial, so there will be only two
possible output, whether it can be zero or one, pass or fail, true or false. So the multinomial, so there can be three or more
possible output, whether it can be
cat, dark or sheep. So in the ddinal so it can be three or more possible
amount of output, whether it can be
low, medium or high. So we can see the output of
logistic regressen model. So there are three dataset, and then we are going to predict the value whether it
can be happy or sad. So in logistic regression, there can be only
two possible output, whether it can be yes or no, zero or one, happy or sad. So in previous class we had discussed about
linear regresson. For linear regresson we have to use the slope and
intercept concept for finding the line
of regresson which separates the independent variable and dependent variable. But in the case of
logistic regresson, we are going to convert our linear regresson graph
into sigmoid function graph. For that you are to use
the formula 1/1 plus E, who power minus beta
naught plus beta one X. So that is nothing
but MX plus B. So the formula of
slope and intercept. So we are going to convert our linear regresson graph
into sigmoid function graph. For that only how to remember the formula for the conversion. So in the first
line, you can see, logistic regresson
model transforms the linear regresson
functions into categorical value output
using sigmoid function. So in the sigmoid function, so value can be two, whether it can be zero or one, based on the S of S. So the terms beta naught will be the
intercept beta one, will be the slope, X will be
the independent variable, and then Y will be the
dependent variable or X coordinate and
then prediction. So main concept will
be we have to convert the linear regressen graph into sigmoid function graph
based on this formula. So after that, we are going to discuss about the differences between linear regreesson
and logistic regressen. So linear regresson
can be used for regress and problems and also
classification problems. But logistic regreesson can be only used for
classification problems. After that, linear
regresson are continuous in nature because
line is continuous. But in the logistic
regressen it can be changed, whether it can be zero or one. In the linear regresson
it creates the graph for the dependent variable and
then independent variable. For the logistic regresson it based on the
particular event, whether it can be true or false. And linear green is trithne and then logistic
gorescen is S shaped. In today's class,
we discussed about logistic goresen in
machine learning. So the concept of logistic
goresson is nothing, but we have to create
a S shaped graph. Our output will be whether
it can be zero or one.
4. Class 3 : Decision Tree: Welcome, everyone.
In today's class, we are going to discuss
about decisionary classifier algorithm
in machine learning. So decision try
classifier is one of the type of supervised
learning technique. So it can be used for both classification and
regresson problems. But mostly it is preferred
for classification problems. So in decisionary classifier, there are two nodes. The first node that is the
decision node or root node. And the second node
will be the leaf node. So the main output of decision
ary classifier is nothing, but it gives whether yes or no. So you can see the first node
will be the decision node, that is the root node. And then you can see the s
nodes like decision node, again decision node in
the left side, and then. So in the left side, you
can see the sub tree. So from the decision tree, you can see two
nodes are separated. That is leaf node. So from the leaf node, we can see the output, whether it is yes or no. So there are two nodes in
decision re classifier. So the first node will
be decision node. From the decision node, leaf node will be separated. So we are going to
discuss about how does decision classifier
algorithm work? So in the first step, we are going to find the
root node for our dataset. So data set, for example, the data set will be fr so fruit will be the root node of
our decisentry classifier. For finding the root node or
finding the best attribute, we are going to need the help of attribute selection measure. So we are going to
discuss about what is attribute selection measure
in the upcoming slide. So after finding the root node, we are going to convert our
root node into sub nodes. So the sub nodes can be
leaf node or decision node. So leaf node can be find based on some conditions
of the root node. So by doing that, we are going
to find our output value, whether it can be yes or no. So that's the final output
from our leaf node. So there are three
steps in decision node. First, you ought to find the root node using the
attribute selection measure. And then second step will be you ought to
find the leaf node. And the third step
will be we are going to find our output value, whether it can be yes or no. So we are going to
see an example for decisentry classifier based on the salary of the candidate. So salary is between
$50,000 to $80,000. So that's our decision
node, our root node. So in the second step, we are going to
find the leaf node based on the condition
of the root node. If the candidate accept
the root node condition, we can generate the
decision node again. If the salary is not
accepted by the candidate, so we can find the leaf node. So the leaf node will
be declined offer. So the output value of the
leaf node will be no so if the candidate accept the salary between
$50,000 and $80,000, so second decision node
will be generated. So that is off is near to home. And then we are going to
find the leaf node and decision node again by using
the previous decision node. So if the candidate accept
the off is near to home, we can generate
the decision node. If the candidate does not
accept the condition, we can find the
output value, no. So by doing that,
the last output will be whether it
can be yes or no. So that's the output
for dissent classifier. So dissent classifier
is nothing, but our output will be whether
it can be yes or no th. Only one tendison
will be accepted, whether it is no or yes, so we are going to see about
attribute selection measure. So there are two types of
attribute selection measure. So the first one will
be information gain, and the second one
will be Gene impurity. Based on these two attributes
and selection measurin, we can find our decision
node or best attribute. So after that, we
are going to see an important term in decision re classifier
that is entropy. So entropy is nothing wet. It is a measure of uncertainty
of random variable. So we cannot find whether
the value gives or no. So that's the meaning
of uncertainty. So that's the
concept of entropy. For finding the entropy, you have to use the fora. So the formula will
be minus P of S, log two Pfs minus P of n log two P of n. So that's
the formula for entropy. So you can see the terms will be the total number of samples, P of S will be the
probability of S&P of no will be the probability of
no for finding the entropy, how to remember the formula. So formula is very,
very, very simple. So entropy is nothing, but we cannot find the value
whether it is yes or no. So for the entropy, we are going to see an example. So we created the data set A, a, a B B B B, and then total number of
instances will be eight. So there are three A, and then five B. After that, we are
going to substitute the values for the
entropy formula. So the formula of entropy
is nothing but PFS, A two PS minus P of
no la two Pf no. So after using the formula, we can find the
entropy value 0.954. So three by eight is
nothing but P of s, L two, five by eight
is nothing but Pf no. So after that, we
are going to see about information gain formula. So for the information gain, so we have to
remember the formula, gain of S comma A equal to
entropy ofS minus summation, S V divided by S, and then dot entropy of SV. So you have to remember the
formula for information gain. And then we are going to see
about guinea index formula. So the formula of guinea
index is nothing but one minus summation P j square. These are all the two
attributions selection measure in decisonry classifier for
finding the best decision node. So after that, we are
going to discuss about advantages of
decisionary classifier. So the first advantage
will be interpretability. Interpretability
is nothing, but we can understand the
decisentry classifier. So we can use the
decisentry classifier for finding the
model predictions. And the second one will
be the flexibility. So decisentr classifier can be used for all
kinds of data types, all kinds of classification
and regress and task. And the third one
will be the robotns. So robotness is nothing, but we can handle the missing
data and we can handle the real time applications using the decision reclassifier. So the last advantage
will be nonlinearity. So decision reclassifier can be used for complex
relationship data. So that's the use of non
linearity. So that's it. In today's class,
we discussed about dicisentary classifier
algorithm in misine learning. So the main concept down decisentry classifier
is nothing, but we are going to construct the tree based on our dataset. So the root node will be separated into leaf node
and then decision node. So the output of dicisentry
classifier will be yes or no. Only one will be the output.
5. Class 4 : Naive Bayes: Welcome, everyone.
In today's class, we are going to discuss about N based algorithm in
messine learning. So N base algorithm is one of the type of supervised
learning method. So mostly the N
Bse algorithm used for solving
classification problem. So the main concept
of N base is nothing but the output of the value
depends on the probability. So some of the examples for N Base algorithm are
spam filtration, whether the male is
spam mail or not spam mail, so
sentimental analysis. So whether the text is sentimental one or
not sentimental one, and then last one will be
the classifying articles. So these are the examples
for N Base algorithm. So the mathematical
formulation of Na base is nothing but P of A sus B equal P of B A in the
P of A divided by P of B. You have to remember
the terms of the mathematical
formulation of Na base. After that, we are going to see an example for Na
base classifier. For that, we are going to use the data set of
weather condition, and also our output will
be play or not play. So we are going to decide
whether the match can be played or not played according to the
weather condition. So in the first step, we are going to convert our
dataset into frequency table. And then we are going to find the likelihood table by using the probabilities
of the given features. So after that, in the last step, we are going to use
our formulation for Na base algorithm to find
our value or output. So this is our dataset for finding our Nay
based classifier. So in the dataset,
you can see 0213, and also you can see
the outlook and play. So the outlooks like
rainy, sunny, overcast. And the play will be yes sun no. So this is our dataset for finding the Nay
based classifier. So in the first step, we are going to convert our
dataset into frequency table. So you have to see
the frequency table. So in the frequency table, you can see the three columns. So first one will be the weather and the second
one will be the yes, and third one will be no. So you have to find the
weathers in our dataset. So the weathers can be
overcast, rainy and sunny. So you ought to find
how many for the overcast and how many no
for the overcast weather. And also you uh to
find how many for the rainy weather and how many
no for the rainy weather. At last you ought to
find how many for the sunny weather
and how many no for the sunny weather
using our dataset. First, we are going to find how many overcast will so yes. So in the dataset,
you can see overcast overcast comes our
own five times. And also, you can see, one time, two time, and then three, and then four, and then five. So there are five for
our overcast weather. So in the output,
you can see five. And then there are no overcast
with the value of no. So that's why zero
comes in the column no. So after that, we are
going to find how many yes for the rainy weather. So in our data set, you can see the rainy. So rainy comes around one, two, three, four
times rainy comes. And then we are going to find how many yes and how many no. So you can see, yes,
yes, two times. And then, no, two times. So two times and two times no. So in the output, you can see
two times and two times no. So after that, we are
going to find how many yes and how many no
for the sunny weather. So in the sun comes
around one, two, three, four, five
times sunny comes. And then we are going
to find and no. So comes, one, two, three, three times comes. And then two times no comes. So in the output, you can see three times and two times no. So you have to find
how many total number allow to find the total of ten, and then you have to find the
total of no, that is five. So we find our frequency table
for the weather condition. So after that, in
the second step, we are going to find the likelihood table
weather condition. For that, there
are three columns. The first one is the weather, and the second one is the no, and the third one is the yes. In the weather, you
can see the weather is like overcast, rainy, and sunny. For the weather, the no
comes around zero times. For the weather overcast
five times comes, and then you have to
find the probability for the values for the
S P divided B, and then you have to find
the total of the dataset. In the data set, you
can see zero to 13. There are 14 values are
present in our dataset. So that's why in the output, you can see five by 14. Pi is nothing but total
number of S comes. So I have to find
the probability, so we have to see
the value 0.35. And then we are going
to find the NE, so no comes two times
and comes two times. So the total will
be four and then divided by total number
of theta set values, that will be 14. So equal to 0.29. So the probability
value will be 0.29. So and then sunny so sunny comes two times no,
and then three times. So the total will be divided by total number of theta
set value equal to 0.35. And then we are going to
find the so you have to find no all 4/14 number of data
set value equal to 0.29, and then we are going
to find all for S, and then all total
will be 10/14. The value will be 0.71. So we have find that
frequency table and lighthod table for our
Na base classifier. So two steps are finished, we are going to
find our last step. For the last step, we are going to use
the N base formula. For that, you have to remember
the formula P of A sla B, equal P of B A, N t P of A divided by P of B. So the P of A will be Pfs. So P of B will be Pf sun. And then you have to
use the formula for Pfs Pf sunny equal
to Pf SNE sla S, int Pfs divided by Pf Sunny. And then you have
to use the values three divided by t equal to 0.3. And then Pf Suny will be 0.35, and then Pfs will be 0.75. We are find from the
previous likelihood table and frequency table. So in the ilihod table of S, the value will be 0171. So we are going to
substitute that value in the P of S. So we are going to
substitute our value generated in the ilihod
and frequency table. And then you have to substitute
the value in the formula. You have to find the
probability of PFS. So the Pfs sunny will
be the value of 0.60. And then we are going to find the probability of P
of no slash sunny. And then you have to
use the formula again, P of no sus sunny
equal P of Suny slasnO in the P of n
divided by Pf sunny. And then you have to
use the values for the Pf sunny slusnO equal
to 2/4, equal to 0.5. So this value comes around
from our likelihood table. And then P of no will be 0.29 and P of Sunny
will be 0.35. At last, you have to
substitute all the values, and then you have to
find the probability for P of no slas Sunny. So the value will be 0.41. So you have to find
the maximum value from the true probabilities. So our output will be calculated
from the value of 0.60. That is P of s Sunny. So our output will
be Sunday day. The player can play the game. So that's it. We find that our nav based classifier
algorithm using the three steps. So in the first
step, you have to convert the dataset
into frequency table, and then you have to
find the lilt table using the probabilities. After that, you have to use the base theorem for
finding the probability of whether the value will be sunny or whether the
value will be rainy.
6. Class 5 : Support Vector Machine: However, everyone,
in today's class, we are going to discuss
about support t or missing algorithm
in machine learning. So support wetter
missing algorithm is one of the type of supervised
learning algorithm. It can be used for both classification and
then regression. So the main concept of support
tar algorithm is nothing, but we have to find
the hyperplane, which separates the
different classes. So that's the concept of
support vector missing. So we have to find
the hyperplane. So in the linear
regresson we discussed about we have to find
the line of regression, which separates the
independent variable and then dependent variable. In the support vetor missing, we have to find the hyperplane, which separates the
two different classes. So the first class will be cat and then second
class will be dark, which is separated
by hyperplane. So that's the concept of
support vector missing. We have to find the hyperplane, which separates two
different classes, two or more different classes. So the fundamentals of
support vector missings, and then we are going
to discuss about types of support vector missins. So the basic fundamental of support vector missing is we
have to find the hyperplane, which separates the
two different classes. So for that, we are going to see an example for support
vector mesane. So I'm going to create a graph. In my graph, there are
two different glass. So the first class will be cat And then second
class will be dark. So after creating the data set, we have to find the hyperplane, which separates the two different classes
in equal distance. So we cannot create
a hyperplane because the distance between
the CAD dataset and dog dataset is larger. For that only we cannot use that so you have to
create the hyperplane, which separates the
two different classes in equal distance. So you have to create
a equal distance. So in that you can see, two different classes
are separated by hyperplane in that you can see, two different classes are
separated by hyperplane in same distance
or equal distance. So this is the hyperplane. So this is the hyperplane. So after finding the hyperplane, we have to find the margin
of two different classes. For finding the margin, you have to create a das
line between two dataset. So we have to
create a dash line. So this is the margin between
two different dataset. So this will be considered as maximum margin or
maximized margin, max margin for SAT, I'm going to call
it as max margin. So center will be hyperplane, and the distance
between two margin will be maximum margin. So these are the two terms involved in support tor messine. At last, we are going
to discuss about the last term in the support tor mechane
that is support vector, for the support t for the support tor for
the support tor, we have to find the closes
for the support tar, we have to find the data point which is closer to the margin. So you can say this data point
is closer to the margin. For that, we have to consider this data point for
the support tor. And then for that, you have to consider
this data point will be the support vector
for the dataset cat, and then you have to find the support vector for
the second class dog. So you have to find
the minimum distance between the data point
and then margin. So you can consider
this point as the support vector for dataset. So this is the support vector. So these are all the three terms involved in support
vector missing. So hyperplane is nothing, but it separates the two different classes
in equal distance. And then maximize
margin is nothing, but you have to create a margin between two different dataset. So the center point will be
considered as maximum margin. And then third term
will be support vector. So support vector is nothing but close points
between the marigin. So we have to consider the closest point
between the marigin. So these are all the terms involved in support
vector missing. So we can see
optimal hyperplane, which separates the
two different classes in equal distance. And then maximized margin. Maximize margin is nothing, but we have to create a
margin between two dataset, and then distance
between two margin will be considered as
maximized margin. And the third term will
be support vector, support vector is nothing but closest point to the margin. So you can see the
closest point. So it will be
considered dog dataset. It will be considered
as CAT data set. So it will be considered as support vector for
the dog dataset. It will be considered as
support vector for CAT dataset. So after that, we are
going to discuss about the types of support
vector misin. So first one will be the
linear support vector misin. So for the linear
support vector missing, we can separate the
two different dataset using the hyperplane. But in the case of non linear
support vector missing, we cannot use or
we cannot separate two different dataset using the hyperplane with
equal distance. So previous we are disturs
about how to separate the two different dataset for the linear type of
support vector messing. But in the case of non linear
support vector missing, we can all separate the
two different dataset with equal distance. For that, we have to convert the diamondsons
of the planes. For example, if the diamond son of the plane is one dimensional, we have to convert the diamonds
on into two dimensional. For one dimens null, you can see the example. So it will be considered
as one dimensional. So you can see the data points. So it will be considered
as one dimensional. For non linear support
vector missing, you have to convert the one dimensional into
two dimensional. For two dimensional, you can
see the Xs and then Y axis. It will be considered
as two dimensional. If your dataset is
one dimensional, you ought to convert the
dataset into two dimensional. If your dataset is
two dimensional, you have to convert the two dimensional into
three dimensional. So that's the concept of non linear support
vector missing. By doing that, we can separate
the two different dataset. For that only, we have to convert the
diamensionals of planes. So in the output, we can see we can separate the two different data
set using the hyperplane by converting the data
by converting the dimensional of one dimensional
into two dimensional. After that, we are going to discuss about the
types of margin. So there are two types of margin in support
vector missing. So the first margin
will be hard margin. So in hard margin, you cannot place
any points inside the hyperplane or
maximized margin. But in the case of soft margin, you can place theta
points inside the hyperplane and
then maximized margin. So soft margin is more efficient
than hard margin because we can predict our output
very easily in soft margin. But in the case of hard margin, we cannot predict our output. So that's the disadvantage between hard margin
and then soft margin. In soft margin, we can allow data points inside
the hyperplane. By doing that, we can predict
our output very easily. In the hard margin, we cannot allow any points
inside the hyperplane. For that only, we cannot predict our output very easily in
the case of hard marigin. At last, we are going
to discuss about the applications of
support vector missing. So the first application
will be image recognitation. And then second one will be
the text classification. So text classification
is nothing but whether the text can
be spam or not spam. And then third application
will be bioinformatics. And then fourth one
will be finance, and then last one will
be medical diagnosis. So these are all
the applications we can use with support
vector missing.
7. Class 6 : K Means Clustering: Welcome, everyone.
In today's class, we are going to
discuss about K means clustering algorithm
in missing learning. So K means clustering
is one of the type of unsupervised missing
learning algorithm. So it can be used
for classification and then recursion problems. So the main concept that K
means clustering is nothing, but we are going to group the similar data points
into distinct clusters. So that's the concept
of K means clustering. Clustering is nothing
but group of data. So we are going to group
similar points into clusters. So in the example, you can see, there are three
different clusters are created from our graph. So three are different
similar data points. So first one will be the
group of blue data points. So second one will be the
clusters of green data points, and then third one
will be the group of black cluster data points. So the main concept of K
means clustering is nothing, but we are going to group similar data points
into distinct clusters. So on the right
hand side, you can see the three
different clusters. So the first one will
be the group of people. And the second one
will be the group of similar data points
of sum warriors. And the third one
will be the group of clusters of fat people. These three are
different clusters with similar data points. So we are going to
discuss about what are all the key terminologies
N K means clustering. First, the first one
will be the centroid. Centrid is nothing but the average or mean
point in the cluster. So that's the center
point of our cluster. So that's the centroid. And the second key terminology
is nothing but cluster. Cluster is nothing but
group of same deta points. And the third one will
be the Elbow method. Elbow method we are going to discuss in the upcoming slide, so we are going to use the elbow method for
finding the K value. So we are going to
discuss about what are all the steps involved
in K means clustering. So the first step,
we are going to find the value of K. For
finding the value of K, we are going to use the
formula of Elbow method. So we are going to see an elbow method in the
upcoming slide. So in the second step, we are going to find the
centroid of our clusters. So centrod is nothing but center point of our similar
data point clusters. So after finding the
centroid of each clusters, we are going to create distinct clusters based
on similar data points. So that's the final step. So in the first step, you have to find the K value. So in the second step, you have to find the
centroid of each clusters. In the third step
using the centroid, you have to group the clusters. For finding the value of K, we are going to need the
help of Elbow method. So for the elbow method, we are going to see what
are all the steps involved. For the Ebo method, you have to create a graph. For the excess is you have
to create the clusters. So clusters can be in the
range of one, two, ten. For the axis, you have
to create WC SS value. So for the WCSS value, you can see the formula
for finding the WCSS. So you have to use the formula
to find the value of WCSS. Based on the value of WCSS, we can create the axis. After that, you have to
create the graph based on the value of
cluster and then WCSS. So in the graph, you
can see whenever you first find the bend value, that will be considered the
value of K. So in our graph, based on the cluster three, our graph will be bended. So three will be
considered as the value of K. So that's the
use of Elbow method. So Elbow method is very, very useful for
finding the value of K. By using the K value, we can find the centroid
of each clusters. By using the centroid, we can group the clusters. So that's the way of
K means clustering. So in the first step, you have to find the K value
by using the Elbow method. So in the Elbow method, you have to use the Xs and Vaxis in the AAs will
be the clusters. So in the Yaxis it
will be the WCSS. So you have to
remember the formula. So in the formula, you have
to substitute the values, and then you have to
find the value of WCSS. After finding the value of WCSS, you have to point
the graph whenever you find the first
bent so that will be the consider as the value of K. So after finding
the value of K, you ought to use the K value
for finding the centroid. So you ought to use the
centrad for each clusters. After finding the centroid
of each clusters, you have to group the clusters. So that's our final
step. That's it. In today's class we
are discussed about K means clustering in
missing learning.
8. Class 7 : KNN : Welcome, everyone.
In today's class, we are going to discuss about K nearest neighbor algorithm. So K nearest neighbor
algorithm is one of the type of supervised
learning algorithm. So it can be used for
both classification and regress and problems. So the main concept of
KNN algorithm is nothing, but we have to find
the distance between our new data point and
our own data set point, which is minimum or close. So that's the concept
of KNN algorithm. We have to find the
minimum distance between our own data point and
our new data point. After that, we are going to see an example for KNN algorithm. For the example, in
the input value, it is unknown to the user, but we are the data
points of two animals. So the first one will be the cat and the second one
will be the dark. Based on the similar
data points, our output will be generated, whether it can be cat or dark. After that, we are
going to see about the steps involved
in K and algorithm. So in the first step, you
have to select the number of K. So K can be
your own value. You have to select the
value of K, larger value. So larger value can be like
five or more than five. In the second step, you
have to find the distance. For finding the distance, we have to use the
Euclidean value. So after finding the distance, you ought to check
the minimum distance between our data points. After finding the
minimum distance, we can predict our output. So I'm going to show an example for that
I'm going to use the paint. We are going to see an
example for K and algorithm. First, we are going
to create a graph. So in our graph, we are created two dataset. So first dataset
point will be cat. So we have created the
dataset for the cat. So this is for the cat. So these are all the
data points for the cat. And then we are created
the dataset for the dog. So that's our second dataset. So this is the data set
point for the dark. We are going to introduce new
data point to our dataset. So we don't know what will be the output of
the data set point. For finding the output, you have to find the distance
between the data points. So you have to find the distance between
these two dataset. So you have to find the distance between these two data point, and then you have to
find the distance between these two and then this, and then you have to find all the distance between the new data point and
our own data set point. So you have to find all you
have to find both dataset, so both dark and CAT. So after finding the distance, you have to find the
minimum distance between the data points. So for example, cat distance is minimum
to our new data point. So CAT distance finded value is minimum to the new
data point value. So then our output will
so that it is cat. So that's the concept
of KNN algorithm. In our graph, there
are two dataset. First one will be the cat and then second one
will be the dark. And then we are
going to introduce new data point to our dataset. We are going to find the
value of the data point. So for finding the data point, you have to calculate
all the distance between the new data point and then
old dataset datapoints. So after finding that, you have to find the minimum
distance, minimum distance. Based on the minimum distance, we can predict to output. So our minimum data
distance will be CAT. So for that only our
output source AT. So that's the concept
of K and N algorithm. So in the output, we can see this is our new target point. And then we are going to find the data distance between
all the data points. After that, we are finding the minimum distance between our new data point and
our data set point. From that minimum distance, we can predict our
output. So that's it. So that's the concept
of KN N algorithm. For finding that distance, there are two types of algorithm or two types
of method we can use. The first one will be
the Euclidean distance, and then second one will
be the Manhattan distance. For Euclidean distance,
you ought to find that distance between
two points formula. You have to remember
the formula. So the formula will
be X two minus X one, the whole square plus Y two minus Y one,
the whole square. And the Manhattan distance, you ought to remember the
formula for Manhattan, X one minus Y one, X two minus Y two, so that's the formula
for Manhattan distance. At last, we're going
to discuss about the advantages and
disadvantages of KNN algorithm. So first one will
be the simplicity. KNN algorithm is one of the easiest algorithm
in machine learning. And the second one will
be the no assumptions. So based on the
minimum distance, we can predict our output. So there can be no
assumption in our output. And then third one
will be the sality. So sality is nothing, but KNN algorithm can be used for both regression and
then classification. And then disadvantages will be sensitive to
irrelevant features. So irrelevant features can
decrease our accuracy, and then computation complexity. So KNN algorithm cannot be
used for larger dataset. So it can be used only
for the smaller dataset. And then last disadvantage
will be curse dimensonality. So KNN algorithm can be used
for the diamonds and one D, two D, and then three D, so it cannot be used
for multi dimensional. So that's it. In today's class, we discussed about
KNN algorithm. So KNN algorithm is nothing, but we have to find the
minimum distance between our own data point and then
our target data point.
9. Class 8 : Random Forest: However, in today's class, we're going to
discuss about random fus algorithm in
machine learning. So random fus
algorithm is one of the type of supervised
learning algorithm. So it can be used for both classification and regress and problem in machine learning. So random fus algorithm is based on the concept
of ensamble learning. So ensamble learning is nothing, but we are going to use two or more classifiers for
our project or problem. So the classifiers like diccentry classifier or
K and non classifiers. So two or more classifiers are grouped and termed as
ensamble learning. For the random forest algorithm, we are going to construct two or more diccentry classifier based on the given dataset. So that's the concept
of random forest. We are going to construct three or more
diccenty classifiers. So in the ensamble
learning techniques, there are three kinds of terms. The first one is the
bagging and the second one is the boosting and the
third one is the stacking. For the bagging, we are going to discuss in the random forest. So bagging is a
fundamental technique used in the random forest. So bagging is nothing, but we are going to use two or more decisentry
classifiers for the random forest algorithm. So we are going to
discuss about how does the random forest
algorithm work? So in the random
forest algorithm, we are going to construct three or more
decisentr classifier. In each decisentry classifier, we'll give an output, whether it can be yes or no. So if the decisentry
gives more than no, our output of the
random forest will be for the
classification problem. For regress and we are
going to find the mean and average of the dicisentry
classifier output. So we are going to discuss about the steps involved in
random forest algorithm. So the first step,
we are going to find the random K data points
from our training dataset. After that, in the second step, we are going to construct
decision tree for that dataset. So in the third step, we are going to find the
value of each decision tree, whether it can be yes or no. So in the last step, we are going to find
the majority output of the decision tree. So if the output S comes
more than the output zero, our output for the
random forest will be S. So that's the steps for
random forest algorithm. So we are going
to see an example for random forest classifier. For that, we are going to create a data set of fruit images. And then we are going to
find the decision tree, and then we are going to predict the value based on
the majority voting. So in the steps first step we are going to
construct the dataset. So the dataset will
be fruit images. In the second step, we are going to construct
the decision tree. So we are constructed decision tree based
on some conditions. So the conditions like whether the fruit is green or yellow. So based on that, we have constructed some of
the decision trees. In the third step,
we are going to find the value of each decision tree. So you can see in the
first step decision tree, apple in the second decision
tree, again, apple. So in the third decision
tree, it is banana. So that's the third step. In the final step, we are going to find
the majority outing or majority output from
our decision tree. So we are going to find the majority output
from our decision tree. So the majority output
is nothing but apple. So that's the output for
our random fus algorithm. For the random fus algorithm, you ought to remember
the algorithm of decisentry classifier, how to find decisontary
classifier output. So we are going to discuss about the advantages of
random fus algorithm. So in the advantages, the first one will be
the improved accuracy. So in the random fus algorithm, we are constructed two or
more decisentry classifier. Based on the majority voting of the decisontry classifier, we have come to the output
of our random for us. So that's increase the
accuracy of our output. And the second one will be the
robotness to the outliers. Outliers are nothing but
unwanted values in our dataset. So we have to remove
the outliers. For the random fus algorithm, it is reliable to outliers. So that's the robotness
two outliers. Even unwanted value
comes into our dataset, our output accuracy
will be increased. And the third advantage
of random forest will be it can
handle diverse data. So it can handle different
type of dataset, different types of numerical
and categorical functions. And the last advantage of random forest will be
automatic feature selection. So automatic feature
selection is nothing, but it can adapt to real time applications
or real time data set. So these are all the
advantages of random forest.
10. Machine Learning Project: My onto the first class. In today's class, we are
going to create our project E commerce product
category classification using logistic regression. For our project, we are
going to use Google collar, so we need to create
new notebook. So after creating
the new notebook, you have to type
your project name. So I'm going to tie E commerce product category classification. Using logistic regression. We are going to classify
the product category. So after typing
your project name, you have to change your runtime. So I'm going to change to CPU. If you want GPU, you
can also use that. So now we are going to
discuss about what are all the packages we need
to input for our project. So you need to import the important package
that is Pandas. So after that, we need to import regular expression and then string and then NLTK package, natural language tool kit. After that, we need
to import a model from the Sklearn package to ti from sklearn dot linear model, Import logistic regression. So we are going to use logistic regression
for our project. You all know that
logistic regression can also be used for
classification project. So after that, we need to input
train test split package. For splitting the data
set into train and test, you ought to input
train test split. So after that, we need to
input accuracy score package. So if we want to find the accuracy score
for your project, you ought to input
accuracy score. So after that, we need to import TF ID vectorizer package to convert our features
into numerical data. For that, we need to
import vectorizer. That numerical data can be useful for training our dataset. So from the NLTK package, so you have to input Stop votes. So stop words are nothing
but it will remove the unnecessary words from
your text or dataset. For that only to import
a package, stop words. So these are all the
packages you need to import. In the next class, we are
going to discuss about our dataset. Welcome everyone. In today's class,
we are going to discuss about our dataset, for our project
ecommerce product category classification
using logistic regression. For the dataset, we are
going to use CSV file. So you have to download the CSV file from the description. It contains the most
important column, product title, and
then category. So based on the product title, we can classify
into the category. Or based on the category, we can classify the product. So we need to import the
dataset for our project. So how to drag and drop and then we are going to import
the dataset using Pandas. So you have to type DF equal t, pd dot, read CSV. We are going to
read our CSV file, and then you have to type
the name of the file. So after that, if you want to view the top values
of your dataset, you ought to use head function. It will sort top values. So you can see top five values
are present in the output. So the most important column, product title, and
then category. So if you want to view
the bottom values, you ought to use tail function. So it will print bottom values. So you can see the
output bottom values. So there are 23,000 values
present in our dataset. So that's it, we have successfully
imported our dataset. Welcome, everyone.
In today's class, we are going to discuss
about data preprocessing. So we are going to remove the unnecessary words
from our dataset, and also we need to
clean our dataset. For that, we are going to use the stop words using
the NLTK package, you have to download
the stop words. And then we need to set the stop words for
English language. For that, you have
to type stop words set Stop words equal
to English language. We need to remove the
unnecessary words in the English language
for our dataset. So to run the code, you can see the stop words are
completely imported. So now we are going to
preprocess the data. So for that, we need to remove the null values from our data. Column name, product
title, and then category. You have to type the
name of the column very, very carefully because if
you type the name incorrect, it will so on error. So you have to change the title, and then you have to
type the category. After that, we need to remove the null values using
the dropna function. So you have to
type D of drop nu. It will remove the null values. So now we are going to
clean our dataset by removing the punctuations
numbers from our dataset. So you have to create a function
def clean text of text. And then we need to convert all the text to lowercase form. And then we need to remove the punctuations from our text. Shoo type text the
equal to R dot subac. We need to remove and then Yotuty dark escape of escape characters,
string punctuations. We need to remove the
punctuations from our string. And then you have to type the
replaced values quotation. Come on, text. So now we have successfully removed the punctuation from our string. So after that, we need to remove the numbers
from our text. For that you have to type
text equal to R d subtract of R D plus. It will remove the
numbers from our text. So after that, we need to remove the unnecessary words
from our dataset. For that, we need to
create a far loop and then check every words
with the stop words. So stop words contains all
the unnecessary words. For that, we need to remove
the unnecessary words. So we have to tag, join
word for word in text, every word, we need to loop, and then we need to split. If the words present in stop
words, we need to remove. You have to type if
word not in stop words. So after that, we need
to return the output. You have to type written text. And then we have to create a new column by applying
the clean text. So you have to type
Df of cleaned title. So that's our new column for
replacing the product title. You have to type
the product title. A play of clean text. So all the preprocessing will
be applied to new column. So that's it. We have
successfully cleaned our text. Welcome everyone. In today's class, we
are going to train our dataset using
logistic regression. So first, we need to convert the features into
numerical data. For that, we are going to use
vector, TF IDF vectorizer. And then we need to separate the features and then
target variable. So you have to type X equal to vectorizer dot transform off. You have to type the
column, cleaned title. So cleaned title will
be our features. You have to convert
the title into RA. After that, you have to type the Y variable for the target. So our target will be category. So based on the category,
we can classify. X will be our feature. Y will be our target variable. So after that, we need to split the data set into
train and test. So you have to type the
variables like X train, X test, y train, white test, equal to
train test split. It will split the data set, and then you have to type X Y, and then you have to
provide the test size 0.2, 20 percentage for the test, and remaining 80 percentage
for the training, and then you have to type the
random state equal to 42. So now we have
successfully splitted the dataset into train and test. So after that, we can
proceed to train our model. See how to type model equal
to logistic regression off. So it will train the model. So it will train the dataset. So how to type model dot
fit of X train train. We are going to train
the train dataset. So you have to run the core so you can see the model is successfully
trained our dataset. So in the next class, we are going to complete our
project. Welcome everyone. In today's class, we
are going to complete our project E commerce product
category classification using logistic regression. In the previous class, we
have trained our dataset. So if we want to download your dataset for that Toto type, the pickle package, using
the pickle package, we can download or use
our dataset model. So we need to open the
model with open off, you have to type the name
of your pickle file. So that's our trained model. Ya to type write mode. It will be considered
as our model file. So inside that, we need to dump all the values
from the trained model. Yo to type pickle dot dump
of model, model file. We are going to
save the model in the product dot
pickle file format. So you can see the output,
product dot pickle. So that's our trained
logistic model. So using that pickle file model, we can create a
real time project which can classify the products. So after that, we need to
predict our output for that to type predict equal to model
dot predict of X test, and then you have to
print the prediction. Also, if you want to
print accuracy score, you can also print
the accuracy score. You have to type, predict, white test, come up, predict. Also, you can print
the prediction. So how to run the code. So you can see CPU CPU CPU, and then you can see the
prediction accuracy score. So that's it, guys, we
successfully completed our project E commerce product
category classification using logistic regression.