okay so good morning all good morning so we'll just start in two to three minutes let everybody have to join then we'll start the session good morning all good morning okay so good morning all yeah so i'm sharing my screen am i audible and is my screen is visible to you kindly confirm yes yes okay fine yes yes yes so good morning all in the last class we had seen the regression part okay in the last part we had seen the regression part so regression means yeah in the last class we had seen the regression part regression means what is what do you mean by the regression what do you mean by the regression that means whenever we are having the dependent variable is in the continuous manner okay continuous manner then we can say we need to use the regression that means we need to see the problem definition okay we need to see the problem definition after that we need to recognize supervised learning is there or not okay if supervised learning how we are identifying the supervised learning that means we are having the labeled data okay labeled data means we are having the x and we are having the y okay that means the class label is also present okay then we are know supervised learning okay after that there will be the one problem is the regression or that one problem is the classification then how we are identifying key regression that means if you are dependent variable okay if you are dependent variable in the data set in continuous manner okay but here your dependent variable in discrete manner okay so this is how we are identifying so from the problem definition we need to identify the data set after that we need to recognize it is the supervised then after that we need to see the is it the regression then if it is regression then we need to follow this particular path if we are having the uh our dependent variable is in the discrete manner that means either the yes no normal abnormal this kind of thing is there dependent variable just like that means yeah the whether the male is spam or not spam spam not spam so that particular things are called as then the uh that particular things are called as in classification so for the regression we had seen the linear regression already okay after that there will be the polynomial regression is also there but now we are moving toward the classification problem that means our dependent variable is in the discrete manner so we need to use the logistic regression okay logistic sorry logistic regression okay so logistic regression is there so what happened in the logistic regression i hope so theory is already known by you so i am directly moving to the uh practical part but i will say in the logistic regression we need the just like this okay this is there so some of the data are here okay some of the data is in the zero and some of the data is in the one okay some of the data is in the one so this is the zero and this is the one that means that if we are doing or if we are making the prediction line then prediction line maybe goes in like this okay prediction line y is equal to mx plus c this will be going like this or it will separate the x and y okay it will separate this particular thing but in what happened some of the point are here some of the point are here so that means their real value is not coming in the zero or one okay that means we need to make the linear equation okay we need to make the linear equation but linear equation we need to make it into the certain range and that range will be the zero one that means ki if if some of the output is more than the zero point five then it belong to the class a and suppose you are value will be in between the 0 to 0.5 it will belong to the class b either the class a will be the spam or class b will be the not spam like this okay so we need to make it but linear line code we need to restrict in between the 0 and 1 so how we can do yes you can do with the help of the one sigmoid function so sigmoid function is called as n okay what is the sigmoid function sigmoid function is just like sigmoid function is just like the mathematical function its range is 0 to 1 its range is 0 to 1 and it is called as the s curve it will make the s curve so we can do the linear equation sigmoid operation so that our value the real value will convert it into the 0 to 1 that means we need to make a thing like this okay it is like this it will be the s shape curve is there okay it is like this the s shape curve so this is the one and this is the zero okay and here we can see it will cut in the 0.5 so this is the sigmoid operation it is one it is zero so here your linear line the linear line ko we had converted into the s shape okay s shape may we had converted that particular now we can say yes very good so what is the formula for this this it is a mathematical thing it is the mathematical thing so what is the formula that is sigmoika formula is one upon e to the power minus z either we are calling the minus z or minus x whatever you can see everything is same now what is this particular z or x so z or x is just like a linear equation yes it is very good 1 upon 1 plus e to the power minus that is beta 0 plus beta 1 x so this is there so this is the logistic function okay this is the logistic function so that means it will always give the value in between the 0 to 1 so whatever value whatever the m that will be the slope and whatever the intercept we are given in the last class in the linear regression we had understood the beta 0 and beta 1 beta 0 beta 1 is the slope as well as the uh intercept okay once we had determined the slope and intercept okay okay now after that we need to put linear line ko is certain s curve we save so s curve will do like this okay so this is called as a logistic function okay this is called as a logistic function so whenever we are giving any x value in this then always will get the y value in between the 0 to 1 when it is based on the probabilistic probabilistic answer okay it is based on the probabilistic answer probabilistic answer means probability term either it will give the answer in between these two so yadi humara ek answer 0.78 aya then it might be possible the second answer will be in the 0.22 that means the probability of the success is like this so the failure is like this that means the probability of the class a is this one then the probability of the class b is this particular thing so if we had set the threshold is a 0.5 okay normally we are setting the probability of the 0.5 then it belongs to this particular class that means what kind of problem we can find out using this either that particular things are the dog or cat okay suppose the dog and cat is there so the class a is the cat class b is a dog so that means of whatever our data set is there numerical okay we had set our things like this okay this is the s curve and we had set the midpoint as a 0.5 so in the sigmoid the midpoint is always in the 0.5 and this is the one point and this is the 0.0 or 1 so this is the s curve so what is this so if some of the value are giving the 0.8 then we can say yes it is a cat category if it is giving the 0.2 sorry 0.7 here then we can say it is a dog category like this like this so this is all about the things about the logistic regression okay binary classification problem can't be solved for the multi-class problem no multi-class problem cannot be solved using the sigmoid operation yes we can do the binary class for this if we are sigmoid operation is there then it might be possible by net only we can do the binary classification okay we need to do the binary classification only so now we are moving now we are moving towards the logistic regression okay now we are moving towards the logistic regression using the Python so this is the formula for the sigmoid although this particular formula and whatever the previously I had told that all formula are the same okay all the formula are same here the things are L divided by why not define the threshold for yes you can do if we are setting the if there are the multi-class classification is there okay then it is not possible in the uh through the sigmoid operation because it is working over the binary cross entropy okay because here in here only we are having the 0.5 okay threshold you can choose a different threshold also but multiple threshold case decide either some of the value are more than this either some of the value are less than this if we are setting the 0.5 0.2 0.8 then sorry 0.1 then it is not possible it is not possible because it will set the one class one class so it is not like this either it is the probabilistic thing we are only finding the one class okay from a class find out karte if that particular value are the 0.7 then other value are the 1 minus 0.7 that will be the 0.3 we are not calculating the 0.3 in through the machine learning okay hum ek hi find out karte but the overall probability will be the 0 that means success ki probability is always the like this okay success probability is like this to failure probability is always the 1 minus something so this is the 0.3 like this the logistic regression function and sigmat function are the same in the 100 percent same both the things are same logistic regression are the logistic regression is the extension of the sigmoid operation but we need to put the linear line over z logistic function ka formula is just like this okay here i had written the sigmoid sigmoid operation is this one but logistic is this one okay log sigmoid is this one and logistic is this one now there is a one more formula for the logistic that is also the same that will be the l divided by 1 plus e to the power minus k x minus x0 this is also the same formula but here l is the curve of the maximum value but here in sigmoid maximum value will be the one the logistic regression is called as a regression because of yes it is because of the because i am taking the regression but it is used for the classification don't be confused or logistic regression is used for the classification okay so beta zero plus beta one x is the regression line we need to fit that regression line between the it between the zero to one that's why we are calling this as a logistic regression although this all this formula is also the same here l is equal to one because our maximum value in the logistic regression is the one and here the k will be the stiffness stiffness means the what is the stiffness stiffness is just like a slope okay so here inside we can write the kx that is the beta one okay and that is a minus x0 or k x0 is the midpoint okay x0 is the midpoint the value of the sigmoid midpoint but in the logistic regression midpoint is always 0.5 so this is the this complete formula this complete formula is the generalized formula if i am writing this for the logistic regression then it is looking like this okay it is looking like this the l is equal to 1 upon 1 plus e to the power minus k is a that x okay then plus k x zero okay so this is there so now this is the 0.5 this value is the 0.5 because it is the threshold value okay so that means it will decide the intercept and intercept line cut over here on the y-axis so this is the thing and this is the slope okay so k we can call as a slope or the stiffness what whatever you can say but here the fixed thing is there 0.5 is clear that's why that particular things are updated while the l will be the maximum value of the curve maximum value of the curve in the logistic is always one so it is like this okay so that's why your formula is like this okay once we had got this particular now we are saying we are moving ahead and we need to see what is the logistic regression so i am reading this particular that you need to understand logistic regression is the regression analysis that can predict the probability of the outcome that can only have a two value because is a linear regression one independent one dependent the similar thing is there also there will be the two value okay so the logistic regression can produce a logistic curve we are saying the logistic current what is the logistic curve that will be the s curve Okay, which is limited to the value always in between the 0 to 1. I had already informed that it will be 0 to 1. Now, logistic regression model, the probability from the each input that belongs to the particular category. So for this particular thing, we are predict that whether a customer will churn or not. So this is just an example. We are taking the one example that we are taking one CSV file. where the our class level or the dependent variable will be the churn or we need to decide whether that particular person will churn or not that means there will be the one class is the churn class and second class is the not churn class that means we need to identify we whenever we are giving the some new value that particular value with the that particular customer value will decide the churn or not okay so this is called as this called as an logistic regression okay so first thing is that we are installing the plotly because we need to plot that particular thing this is a optional step but here we had installed we had import all the library just like a pandas numpy made plotly plotly okay or time whatever everything we had uh installed okay but you need to you need not to understand each and everything only you need to understand the objective behind this so what is an objective of the logistic regression to learn the theory behind the logistic and we are able to implement the logistic regression without the built-in library there will be the built-in libraries also there because through the sqlern you can directly run but i'll say i'll say i'll tell you the little bit of the things in the explanatory manner that we have seen the is through the escalator the same things are applied for the logistic regression also that we are running with the help of the uh scratch as well as the with the help of this okay with the help of the scalar we'll see both the things okay so in this particular thing we are solving using this logistic function and this logistic function is called as this this is the l this is the maximum value now the maximum value is always one in the case of the sigmoid that is one plus e to the power minus kx plus kx0 we are saying like this so we are fixing the fixed thing is the euler number that is the ease is always the 2.71 because it is the predefined while x0 is the point the sigmoid midpoint on the x-axis x-axis particular point will cut down okay and l will be the maximum value so the maximum value will be the one and k will be the stiffness in the curve okay stiffness in the curve is always called as an slope so now what is the logistic regression what is the logistic regression that is the theta t into the x theta t into the this is just like a weight this is the just like a weight so whatever weight we are taken or we are mixing with the input so this is an input and this is we are adding the weight normally what happened we are given the model there will be the some weight is there okay suppose that this particular things are there so we need to give some of the weight 10101 like this okay some weight is there and similarly there will be the x is there just like 101 so whatever the x value is there we need to map the bed the weight multiply with this this is called as an z that is the theta into x and why we are doing the transpose to match the dimension of the x x dimension magically we are doing that particular thing okay so this is how we get the z okay after that we are putting this z into here and we can see this particular thing so how we can now we are identifying how we are setting the sigmoid so how we can set the sigmoid so sigmoid is it is taking the x as well as the bed so whatever is there we need to do the dot product then z is equal to np dot dot x in comma bed and we can put this z into here that is one upon one plus e to the power minus z so this is the python code we had implemented so whenever we are required in the sigmoid we can use this now what happened at the end we got some error okay at the end we are got got some error that means whenever we are doing the classification at the end at the end what we are getting we get the predicted point okay at the end we are getting the predicted point here hapa dekho jabam sigmoid operation perform or logistic operation perform we had give the input okay and we got some of the output so this output will be called as the predicted output then there will be some actual output is there now the actual output minus the predicted output is called as an error okay it is called an error so we need to reduce this particular error okay we need to reduce this particular error and this is an objective of this where did we perform the transpose of the matrix theta it's up to you it's up to you we need not to transpose okay sometimes we can transpose but sometimes we need not to transpose transpose is just like for matching the x okay just like this okay suppose that it is not always the thing suppose x is equal to uh 2 into 2 okay and the theta is always into 2 into 2 okay then no need the this is the theta and this is the x yeah this is the requirement suppose that this is the 2 cross 1 okay it is the 2 cross 1 suppose that the this is 2 cross 1 and this is the one sorry this is again 2 x 1 okay theta is also 2 x 1 so 2 x 1 2 x 1 multiplication is possible not possible so why we are we are doing the transport so that it can become the 1 x 2 now the things are there okay 1 x 2 may the possible is there the this is like this we are doing the transport so that our multiplication is happened that's why we are doing the transfer so if we do not transpose the matrix then how dot product will work dot product is just it's up to us that how we are taken the bed bed ko lena is in our hand okay it is in our hand ki hume kesa kis matrix ka lena hai okay kis matrix ka lena hai that is in our hand so we had fixed x or weight weight hum ne same le liya just like 2 cross 2 or 2 cross 2 so we can easily do the dot product if it is the 2 cross 2 2 cross 2 then we can perform okay this is the 2 cross 2 this is also the 2 cross 2 so 2 cross 2 operation we can perform this is the 2 and if 2 cross 1 then here 1 cross 2 is required so dot product 2 matrix Christmas dotproduct is the matrix multiplication only okay dot product is the matrix multiplication only okay we multiply multiply do not know format go if or matrix multiplication possible whenever this particular or this particular same match or output is going like this this mathematics said I understood that particular things already you know by you okay yes so at the end what happened at the end what happened we got some of the error sorry we got the predicted value and we got the actual value now the actual value minus the predicted value is called as an error now we need to reduce this particular error okay we need to reduce this particular error so reduce carnically what things are there so for reducing this we are using one clear concept that will be called as a gradient descent okay gradient descent so what is the gradient descent okay can't we use the linear regression is the class yes we are not saying using the linear regression is the classification because linear regression will give the value in the any real value okay linear regression any real value just like the 500 okay just like the 500 but here we or if we had said the 0.5 okay suppose that here the thing are there if we are performing the linear regression it is going in this direction sometimes this will give the 500 and sometimes the negative value is giving the 200 so yet 200 value week class image of your 500 class image but to this 200 value are coming in here and 500 are coming here so if 0.5 is the setting criteria then some of the value are here some of the value are there that's why okay so and logistic regression as the regression while having the continuous sigmoid tender yes yes yes yes yes there will be the threshold value is there so for the classification we require the some threshold value that's why we are using this okay so now we have a loss ko minimize karna hai loss ko minimize karna either we can the loss minimization either we can say the uh what thing the loss minimization is the one thing and the second thing is the uh the error okay so error reduced currently we are using the gradient descent and what is the gradient descent that we need to understand so gradient descent is just like a derivative of an error just like there is there will be the this is the error y minus y bar okay but here we are using the binary cross and property okay cross and property and what is the gradient descent gradient descent is just like why we are using the gradient descent to update the bit okay to update the weight job we use because we got some here you need to understand we got the error okay we got the error error now suppose that that one is there but we need to reduce it so how we can reduce it okay reduce because the input is fixed we cannot change the input so what we can change the theta we can change the theta so we can change the theta randomly liya tha usko update kar de te okay we need to update the data update the weight to update karne ke liye weight ko we are requiring the gradient descent and what is the gradient descent that is the derivative of the error with the respect to the theta so this is the gradient okay through this we are getting the new weight that will be the old weight and plus the learning rate into the d divided by the d theta so this is the formula for new weight okay this is the formula for the new weight so this weight new is also called as a theta okay so theta old that means previous weight may add current with some of the learning rate i will say what is the learning rate in the later part but this is the gradient so that's why the gradient is important thing okay that's why the gradient is important thing okay yes so this is the gradient i will say that particular in the detail in the deep learning part but right now you need to understand this is the gradient only okay so what is this so what is this this is the sigmoid of x into the theta this is the h okay so this is the favorite topic of the nds yes 100 percent uh favorite topic gradient descent is a very important topic but i'll tell this particular in the detail in the deep learning but right now you need to understand i am repeating i am repeating no issue why what is the gradient descent okay what is the gradient descent gradient he said huh so essentially our goal is to find the change in the error and adjust the way by it yes very good now what is this we got some of the error okay we got some of the error there will be the actual point is there our actual result will be the 0.8 but our predicted result is the 0.6 then 0.8 and 0.6 will be the 0.2 will be the error okay yes now we need to you reduce this particular error for reducing the error we are using the gradient descent concept gradient descent concept kya hai to reduce the error so that means what how we reduce the error by updating the weight hume weight ko update karna hai now weight ko kya update karek hai how we can get update the weight through the gradient descent and what is the gradient descent it is the derivative of the error with respect to the weight okay weight ke respect me so weight ke respect me error ka derivative is called descent gradient okay now we got the gradient suppose that mathematically you what the gradient derivative with respect to theta we got that now how we need to update the weight so we are we need to set the new weight we need the previous weight then we need to give the plus minus i am also writing the minus sometimes we need to reduce it sometimes with now with the help of the learning rate learning rate is just like okay learning rate is just like learning what is the learning rate here we got some of the okay sorry sorry sorry yeah so this is the thing and this is the zero this is the zero error okay this is the zero error and we are coming here so this is how we need to go okay this is how we need to go till the zero error this is the momentum so this momentum is called as an learning rate so this is called as an learning rate so this learning rate could not be so much high so much low so it is going in that direction it will never reach it will never reach to zero is the movement okay and if it is too slow so that means we need to pitch some of the value so this is the learning rate okay so this is the learning rate learning rate case offset derivative ko move karana so this is how the gradient descent is there okay it will never yes it is it will never reach to the local minima okay if it if our learning rate is very much uh slow or we can say if our learning rate is too much high or too much low in the both the cases we will need never reach to the local minimum in the slow we can reach but it will take the time but in the high we are never reached to the local minimum okay and in the mathematics you had already know in the mathematics you had already know about that what is the local how we can achieve the local minimum through the derivative yes so we had did the derivative and this derivative is called as an gradient descent but it is too low we can reach what it will take yes it is it will take the lots of time we will reach but it will take the lots of time that's why we will not choose the very slow and very high okay can you give me the clear real time example with respect to this learning rate selection uh the clear real time example is just like okay suppose that we need to classify the dog and cat okay suppose that we are we need to classify the dog and kid okay so there will be the two classes there one class is the dog and second class is the kid now we are applying the logistic regulation it will give kia 0.7 percent 0.7 isn't coming as a dog while the other will be the 0.3 so one image is there a image the answer is 0.5 and 0.7 and 0.3 now actually actually that particular value is the one that it is 100 percent dog so 1 minus 0.7 is a bacha hua is the error okay suppose this is it now we need to get the error as a 0.3 but we need to reduce it to 0 this is the ideal condition so we need to reduce it so reduce carnival yes we need to get the derivative of the error with respect to the derivative of the theta because we are taken some of the theta over there yes i will say a visual representation is there just wait here everything is there i am telling this particular this is the complete visual representation but right now you need to a little bit wait okay linear regression has a limitation when we are yes linear regression has the uh limitation because it is giving the real value it is going beyond the zero one that's why we are applying the logistic over okay so this is there okay if i'll give the complete visual representation okay just wait so now we got the sigmoid value and we are getting the x and theta okay now we got the loss okay now we got the loss okay loss that is the yt log h minus 1 minus y log 1 minus h what is this this is the binary cross entropy okay this is the binary cross entropy okay this is the formula for the binary cross entropy so what is why why is it but one particular predicted point that will be the give the log h log h is the sigmoid after sigmoid we had applied so log and what is sorry sorry sorry yeah so zero seven key value and one minus y transpose is also giving the remaining thing so it is the binary cross entropy this is the formula for the binary cross entropy so we will use this particular now we need to implement the loss okay so error here the error will be regression what kind of the error we had used we had used the mean sorry mean squared error okay mean squared error but here we are using the binary cross entropy binary cross error okay so cross entropy is the one formula that we are using so this is the one y m one y m is the total number of the observation is one y m that y t is n whatever the output we are getting we are giving the log h and one minus y one minus y if the y will be the 0.7 then the one minus y will be the 0.3 and the log one by one minus h so this is the formula for the loss in the we are using for the logistic regression it will not work if there are the many outlier which do not fit the boundary yes it is there because is asking sir can you please explain how you come with this loss from equation loss equation you need to understand okay that means if we had find and if there will be the the one class or iska error is something 0.7 sorry it's it's y value is 0.7 good you understand yes its value is the 0.7 to remaining joga 1 minus y this is the 0.3 so what we can do that y into log h this is the sigmoid formula okay to sigmoid formula y value convert 0 to 1 okay minus this is the formula for the cross entropy you can search this is the lost thing then 1 minus y this is the this particular thing then it is the log of h okay so here you can see this particular formula is there sorry sorry 1 minus h so whatever the value is there we can find out so this is the complete formula of the binary because there are the two things Pahla Observation और दूसरा Observation So, दोनों का loss calculate करके ही Final loss निकलेगा So, this is called as a loss Okay, once we are determining this loss Then we need to apply the gradient descent over this Okay जैसे हमने linear regression में क्या किया था Linear regression में हमारा y आया था और y वार आया था So, हमने क्या कर दिया था Y minus y वार We are doing the squared And that will be the sum of the squared error And we are divided by the n so this is the mean squared error but here we are using this particular loss because because we are having the two things one y or one minus y don't be confused with the transpose transpose it's just like sometimes we are requiring the transpose sometimes we are not requiring the loss the loss will be calculated for both the class hundred percent this is for the one class this is for the second class and we are requiring the sigmoid that's why we are using this edge because edge we are assuming and edge we already have the sigmoid here you can see the sigmoid this is how we are finding the sigmoid find out we got the loss we have to represent with the help of the formula is there only one method the gradient descent method right now the gradient descent method is the very good method and there will be the one more method is there that will be the maximum likelihood method okay maximum likelihood method but we are not using that okay the gradient descent method is the very good method it will use in the deep learning also okay so it is it we are using in the deep learning model also so here we can see the aim will be the total number of sample and y will be the target class okay so this is how we are finding my target class now we are implementing this particular loss so loss can be what things are required only the h and only the y so this is this we are returning so what is the goal of that the goal is to minimize the loss okay we are minimize the loss why means the increasing or decreasing the weight sometimes we need to increase the weight and sometimes we need to decrease the weight that's why we are putting the plus and minus okay here i am writing the plus as well as the minus okay sometimes the old weight message is minus sometimes old weight set plus karna why so here sometimes the error is coming here and sometimes the error is coming here so if it is going in downward direction then directly sorry in the hair the positive thing and here the negative thing so So, we are requiring this particular condition. Okay. So, you are getting this. So, this is called as a gradient descent. 1 by m is just like divided by there will be the number of observations. Just like 10 observation is there. Okay. 10 sample is there. That's why we are divided with this. That's why we are divided with this. That's why we are divided with this. That's why we are divided by 1 by m. Suppose that 10 had our time. During the training, 10 samples had. okay if 10 sample is there then we need to get and we need to divide it by the 10. so this is how we got the loss okay so this is called as a loss that we need to define and what is the use case goal goal goal is to minimize the loss by means of increasing and decreasing the weight which is commonly using the fitting okay which weight should be the bigger and which weight should be the smaller that can be decided by the gradient descent or gradient descent is just a derivative of the loss function that we are using so here you can see the gradient descent is the weight okay sorry the uh derivative of the loss divided by the derivative of the weight okay so here we are doing this particular things and this is the formula this is the formula for the new weight so this is the weight equal to previous weight minus alpha this alpha is the learning rate we are writing this could be the not very much and very less and this is the derivative so this is how we are updating the weight so now we are implementing the gradient descent so this is the gradient descent we need to get okay so this is the gradient descent formula and this is the update the weight okay so this all things we are writing okay we had got all the things okay now we said all the things we got everything we have said the sigmoid we said this so we i hope you had find out or you understood all the things okay we had said we got the gradient descent how we can update the bit we had seen all these things we'll see all the gradient descent related things in the deep learning aspect after that one or two class you will get the complete understanding of the gradient descent but right now you need to understood that particular thing okay because in the logistic regression we need to understand this particular things also request to help us again while explaining how the weight are updated from the first round of random weight selection to the next iteration from the algo okay suppose that okay now you need to understood i'll tell the complete story in just five minutes okay we are having the input okay and suppose that input are the one one zero suppose that okay now we need to make a bet this is the three cross one okay now we need to make this particular thing okay this particular so here one is there and we need to make the one cross three anything you can take so this is there so we are taken this particular okay this as a weight now we got the output input as well as the weight okay x or isco we are taken the x it's go theta okay we are taken the x and theta so x and theta we got okay and we need to put it into the sigmoid so that we get the value in between the 0 to 1 okay now we got the value okay i hope this particular things are fine the h the x theta this is the dot product now we got the value now we got the value 1 as a 0.7 so 1 minus y will be the 0.3 okay this is there now we got the thing we got the thing now we need to find out the loss with respect to the theta okay now what is the loss 1 minus m total sampling is there and what is this y into sigmoid with respect to the theta okay sorry the sigmoid sigmoid is h okay that will be the what is this the h we can we are assuming h will be the output of the okay sigmoid so you happen we can write the log h because log is giving sorry this is the minus then the second 1 minus y and log 1 minus h so this is how we are finding the loss okay so this is an error now what we can do we need to find out the loss sorry we need to find out the loss theta with respect to the theta so this is called as an gradient descent okay so once we are finding the gradient descent what we can say we need to go and update the weight how we can update the weight so this is the new weight that we need to find out this is the old weight minus or plus whatever thing is there that is the learning rate okay that is the learning rate that is the loss theta with respect to the theta so this is how we are updating the weight now next time we are using this new bed okay this new bed now again x will be the fixed thing that will be the 1 1 0 okay now updated weight is there that will be the new bed and that is something that is 1 cross 3 so sorry three cross one here one cross three okay we had updated the weight okay that will be the first time first time here first time we had take the random weight okay first time we had taken the random weight but here we are taken the updated weight so we wait update one okay now again we need to follow all these things x theta h this h is the sigmoid and we got again by now y will be the 0.72 and 1 minus y will be this one now our error is comes as a 5 sorry now our error comes is the minus y log h minus one minus y log one minus h okay log one minus h so might be possible which leave our error 0.2 the upper update okay minus one that means this is how our error is reduced sm multiple time we need to run and we will get the this particular value so i had clear I'd given the complete understanding about the logistic regression. Sir, what why we use the y transpose? y transpose use karnei ki meaning bhoat açho saamjho. Okay, sometimes what happened? The q humnay dhe diya is tarikhe se. Sorry, q nahin. Theta humnay set kal diya like this. Okay, humnay theta set kal diya 1, 1, 1. So, is it possible the 3 x 1 or 3 x 1 ka multiplication ho saktahay? not possible that's why we are converted or theta transpose okay sometimes what happened we had given the three cross one okay suppose that and here also we had created the three cross one is it possible this is the theta and this is the x okay x to fix because it is we cannot change that's why we are doing the transpose of this we have this transpose of this so this transpose करेंगे तो 1 x 3 बन जाएगा, now the computation is easy, okay, so transpose हमें safe देखने के बात करना है, it is not like this, that's why in the coding part it is mainly written, okay, in the formula it is written, you can do the transpose, because normally what happen just like 3 x 1 or 3 x 1 he will generate but we cannot do the dot product in between these two that's why we are doing the transpose so that it can convert into the 1 x 3 so that we can perform the operation and we can do the 3 x 3 so this is the things that we need understand sir when we are getting the minima with the gradient descent differential why we need the learning rate did not get it to get that okay i am i am giving this particular answer okay so this is there okay this is how our error is there suppose that our error is the zero we are requiring error as a zero so this is the desirable condition okay this is the desirable condition now we got the error here okay we got the error here now we need to reach till the minima with the help of t loss theta with respect to the d theta so this is the gradient descent gradient descent ko kis momentum ke sath move karna hai till the 0 okay till the 0 to kis momentum के साथ करना है that means यह जो है चो derivative उसको 0.1 के साथ multiply करना 0.2 के साथ 0.001 के साथ 0.002 के साथ so this momentum will be decided by the learning rate कि किस momentum के साथ हमें 0 तक पहुचना है okay किस momentum के साथ 0 तक पहुचना है that is called as an that particular thing so there will be i hope this particular things are understand by you okay that particular momentum we need to decide and we need to give some mathematically value that can showcase the loss gradient that is the thing okay then there is a one more question so sir it is not always transpose but not able to take the dot product we do the transfer yes 100 percent true this particular question then we need to take attack the gradient tell us which direction to move the learning rate tell us how we get step yes very good we are taken the log of the sigmoid to convert the multiplication into the addition it is just like we are setting the value because our value is one zero ke form mein bhi a sakti hai toh log hamehsa logarithmic will set the thing ki logarithmic hamehsa hamehko log odd log odd hota hai isko bolte hai log odd log odd will give the value in the partition basis okay the cons of this optimization technique that gradient descent is a iterative process can you share when we can you not use the gradient descent and go for the maximum uh yes there will be the two thing is there one is the maximum likelihood iteration while the gradient descent is the uh second process but the gradient descent is the iterative process and the maximum likelihood is the not the iterative process so whenever you need to take the uh uh the gradient descent is always the good choice okay the gradient descent is always the good choice but the maximum likelihood is never guaranteed about about the loss updation okay but we can use the maximum likelihood estimation also but here we are using the gradient descent gradient descent will always give the guarantee about the uh reducing the error okay so this is this is all about the uh this is all about that particular thing okay so now we got the loss things we got everything okay now i think we are done with understanding the mathematical things so we learned the logistic regression that can be used for the classification because the output is always in between the zero to one now we can understood the two common technique to optimizing the logistic regression that can be the minimizing the loss now we learned the difference between the gradient descent as well is the gradient ascent gradient descent is just like for gradient descent is just like a positive direction so we now we had now understood each and everything okay now we need to take a one data set okay now we need to take a one data set in in this particular data set we need to decide whether one particular things are having the churn or not okay so churn or not okay so decide carrying it that whether that particular customer will churn or not so in the data set here we are loading the one data set so our problem is the churn or not okay so churning is just like a one class that will you can understand if it is churn then a category if it is not churn then it will be the b category so we need to decide based on the other parameter other independent variable gets upset dependent variable whether that particular value will be the channel or not so data is equal to pd dot read csv and this is how we are taken the csv file now we need to print the data size we need to print the row and column and we need to make a shape of row and column so here you can see we are having the data set okay now we are having the 7043 as a row and there will be the 21 column is there so 21 column means the 21 feature is there out of this we need to decide which column we need to take as a dependent and which column we need to take as an independent okay so here the print is this particular thing now we are having the data frame and we need to set the data dot d type okay now you can see now you can see okay now here the data type so customer id is the one feature now the gender is the another feature senior citizen in another feature partner so this is like the 25 column is there and there will be the last column is there that will say the classification kind of thing that will say whether it is churn or not okay it will decide so df is equal to data dot copy okay it will say the data dot copy so we are doing the we are copying that and we are putting into the df okay we are putting into the ddf so we got the data set we have load the data set and all the things we had decided okay now we are having the lots of column to simplify this we are using only the two feature we are not using the many feature so we are using the tenure and monthly charge as in thing okay so the target would be the chan target feature target feature means the uh dependent feature okay so dependent feature will be the churn and while we are taking the tenure and monthly charges for showing some of the visualization so it is not that much uh important thing so we had do the eda part once i am giving this particular ipv to you you can run and you can see so i am explaining this particular so this is the eda part eda is just like the exploratory data analysis so we are setting the criteria we need to see the independent variable okay so what is the independent variable the tenure and monthly charge so we are making one graph that will say on the x-axis there will be the tenure and on the y-axis the monthly charge is there these things we need not to understand we had already seen the eda part or eda part yes or no is there that chan is giving the two category either that particular things are chan or not so based on the tenure and monthly charge on the x-axis we are taken the monthly charge on the y-axis we are taken the tenure and accordingly there the blue dot is called as then uh blue dot is called as an yes category and the orange dot is called as a no category so this is there similarly we are doing the one more thing we are plotting the tenure versus the chan so it will give this particular it will give the yes category and then the blue will tell the no category so based on the tenure we are whether that particular that particular customers will turn or not we are decided this the same thing is their monthly charging on the y axis that particular will turn or not so there will be this particular thing is there now if we can see the target whether how many things are the churn okay so that means the no category is having showing the five one seven four that particular row is showing the no while this one eight six nine things are called as a yes category so now we are doing the eda part of eda part seven what things we had decided we can see the clear difference between the our target class so we had decided that our target class will be the churn or independent variable we had chosen the tenure as well as the monthly charge okay so we had used now the main things comes into the picture that will be the logistic regression okay so logistic regression you need to understand okay now we had said the class okay now we had said the class so inside the df we made the one class thing or class we had applied the chan and we had applied the lambda function lambda function will tell if your value is yes because that will be the object type हमारा जो वो column है chan वाला column है that will give either yes or no so if it is giving the yes we are converting it into the one तो yes को 1 से replace कर दो और बाकि जो भी other बच्चा है that will no को 0 से replace कर दो तो हमने एक नया feature or a new column design that will be called as in class and that will give the one zero so whether the chan is one sorry whether the chan is yes we are giving the one and whether the chan is zero the is no we are given that particular value as a zero so we had said the class column so this is the that particular thing now we need to set the independent variable okay or independent variable set karna that will be the x to hume isme kya kal diya humne set kar diya x ke under that will be the tenure or monthly charges so we are copying this particular thing so we had said inside the x we had given the tenure and monthly charges inside the y we had given the class okay so this is how we said the x and y now we need to make a thing that we need hum ko iteration perform karna hai so first time we need to take some of the theta sum of the x also okay so we need to match the start time that is a time dot time so this is the start time we need to set okay and calculate how much training time we are taken for one iteration okay okay that we need to find out okay now we need to set the number of iterations now we had said that means that means then one lap time okay now we had said the intercept okay now we had said the intercept we had given the one name that will be the intercept that is the np.1 and we had given the same okay so this is the we had given ki humne sapme one set kar diya so intercept is just like 1111 set set kar diya okay now why we are setting the 111 okay now how why we are setting the 111 in the intercept now we are get the x or x ko humko concatenate x or intercept me okay x or intercept me humne kyou one one set just like this here you can understand here you can understand just like your shape is just like your x value will be the two one one three one four okay suppose that this is your x value okay x value to intercept k through we can fill it into the squared winner so that i'm three cross three bana diya okay i'm the matrix for three cross three bana diya again it's a uh just like it's uh we can say the optional step so that we are filling and we are got to x mp.1 will give always the 1 1 value now we need to concatenate and we had prepared the 1 on the axis basis axis basis column we got the x okay we got the x now we got the y how we can identify the before we are going the we need to decide the theta and theta first time np.0 so the first time we are taking the 0 0 0 0 0 0 0 0 0 0 0 now we got some of the value over the Y and then we will update the weight. Okay, first time we have taken the 0. Either you can take the 0 or either we can take the theta. So we had to do this particular. We have prepared this. Now we need to give the number of iteration. And in that iteration, what do you get? The first thing, we need to apply the sigmoid and we are putting the X and theta over there and we had already made the sigmoid function over there. now we got the age from this sigmoid ka hai oopar bana rakh hai sab se oopar here okay here we had prepared the sigmoid so here we are giving the x as well as the y it will return this particular value and it will give to that okay yeah okay we got the age we got the age now after that we need to get the gradient okay now we get the gradient now we for the gradient we required the x we require the y whatever the y comes in the very first iteration now we got the h for this case we got the gradient now we need to update the theta okay we need to update the theta to update weight loss we had already given 0.1 is in that particular thing gradient we are getting from here and theta the previous theta is there now we got the new theta and new theta ke बात फिर से यह program run होगा it is going like this okay it will run many time and it will give the value okay it will give the value okay then at the end we need to say the training time कितना training time लग रहा है हमारा पूरा काम करने के लिए after that we need to fix the learning rate as well as the iteration okay so this is how we are saying so यहां पर हम perform कर दे रहे हमारा operation so this is how our training time is calculated learning rate is there and total number of iteration is there okay now we are saving it to the result okay now we are saving it to the result so we are applying the sigmoid and x or theta so last 10,000 ke baad okay 10,000 oh sorry this is aakhri step that will be the last iteration last iteration mein jo bhi hamara x rahega x toh same hi rahega we need to apply the sigmoint and whatever the result is there we need to print that particular result and that result will be the most efficient result we are assuming after that one leg iteration we got that particular thing so same weight is the very important for the model accuracy along with the descent gradient can we please go little more in the detail yes hundred percent we will go we'll go in the more detail in the deep learning module okay in the next to next class we will go in the more detailed manner you will get everything but right now for the logistic that particular things are not that much important that's why in the next class i'll tell the complete thing about the gradient as well as the complete forward propagation and backward propagation you will see complete thing in the next class but i'll cover in today's class is a gradient sorry logistic because this is the machine learning concept from the next class on but i'll start with the deep learning concept okay you will get the complete things okay so after the one lakh iteration you will get the result okay and i am printing this now what happened we got the result okay we got the result okay now after the result we need to find out some pred value okay that what is the prediction so here we are setting the criteria if x is more than the 0.5 then we can say it belongs to the sorry less than 0 it belongs to the 0 category and if it is more than the 1 then sorry more than the 0.5 it belongs to the 1 category okay so according to this we had set the threshold now threshold is in our hand okay now we are fixing the 0.5 is a threshold if it is more than this then we can say the that particular value is belonging to the class a otherwise the class b now there will be the some prayed value is there okay and so this spread value we need to check with the class and class is what is the what is inside the class that will be the actual point sorry that will be actual point so this is how we got the accuracy okay now our accuracy is the 77.93 so whatever the model we had created it will give the seven around the 78 percent accuracy okay so this is all about the scratch coding of the logistic regression scratch coding of the logistic so whatever i told in just one and half hour one hour one hour ten minute all the things we can do using the this particular okay using the escalon okay using the escalon module we can do it in the very small step so how we can do so this is the complete thing same this is also the same thing this is also the same thing okay all the things are same okay all the things are same but what we are changing only that's it okay only this particular things are changing so inside the sklearn there will be the linear model is there inside this the logistic regression is there now we need to use the logistic regression and we need to use the fit intercept that will that means ki x may intercept dalna ya nahi 1 1 1 okay now we need to fix the maximum iteration now we need to fit fit that particular model between the tenure and monthly size with the help of y because we had fixed the y because inside the y there will be the class and there will be the x to that particular thing now at the end we are getting this the same thing is there now we are storing the result tree and we need to use the predict method so there will be the two method is important in the a scaler in the in the last class also in the linear regression we had used the two thing so that will be the fit method fit method is used for the training while the predict method is used over the uh can be used for testing that particular things or evaluate that particular thing so the predict method is used over there so we are using this and we got the result and from here we got the accuracy that will be the 78 so whatever we did we are doing that particular with the help of the just five line okay one two three four five this five line will give all the things similar as the previous but for understanding purpose that's why we are doing with the scratch okay so i am little bit fast in today's class but that you need to understand because our main thing is to understand with the help of the scratch fooding okay if you got the proper understanding then here we need not to make the gradient we need not to make the theta we need we need not to make each and everything only we need to give the input and we need to give the output and we can fit this particular meter so only this particular line is important the clf dot fit and we need to give the input as well as the output we need not to decide the theta we need not to decide the gradient descent all the things are inside the logistic regression okay so that's why the sklearn library is very much important okay so if you are not you if you had not understood anything okay so at least you need to understand that inside the sklearn we are having the logistic regression okay and we need to fit or we need to call this logistic regression and we will get this particular thing okay we'll get this particular things now we need to print okay and we got the another method that will be the predictive and for the predict we are using the x value x value means the tenure and monthly charge and we are getting the result and this is how we call the accuracy okay this is how we got the accuracy okay this is how we got the accuracy and our accuracy is this particular thing so how we can we check the class probability cross probability probability is just like this the sigmoid sigmoid itself is giving the probability okay sigmoid jaysay sigmoid apply karoke x or theta ke upar jaysay h okay we are given x h is equal to sigmoid okay x and theta suppose this is called sn okay so what is this one upon one plus c to the power minus z it will always give value in between the 0 and 1 so if it is giving the value y key value 0.7 so this is the class probability okay this is the class probability of the a if we are setting the 0.5 more than 0.5 we are saying the sigmoid also give sigmoid operation ka meaning he is a probability answer sigmoid itself give the class probability okay that's why we are using the sigmoid operation sigmoid operation use meaning that's why we are choosing the sigmoid okay have you got the answer nishant sigmoid operation is only thing okay okay and through threshold we can decide whether yes it is through this what we have to do is we have to find out the sigmoid of answer once we are getting the answer then we need to set the threshold i'm gonna set threshold set k 0.5 if it is more than this then we can set it is chan otherwise we are setting it is not chan like this okay so i hope so things are clear with you in the next class we will start the deep learning where you will get the complete understanding about the gradient descent and the bait updation and all the thing is there okay so i think that things are clear with you anybody having any doubt then let me know otherwise i am ending this particular class okay i'll upload this particular ipynv file okay i'll upload this particular ipynv file with you okay uh sir kindly attach the today's demo csv 100 i'll upload 100 okay kindly attach the today's demo csv data files including last demo okay i didn't give the csv file okay okay sorry for that i'll upload i'll upload the csv file also i'll upload the this the gradient descent and the gradient ascent is just like this okay sometimes you will get the value here sometimes this is the gradient descent okay suppose that we are going in that direction suppose that we are going in that direction this is the gradient ascent okay gradient ascent okay so this is the gradient descent that means our gradient come ho raha hai but gradient here okay sorry sorry sorry sorry screen is stop ho gai na no issue no issue no issue i need to reshare it yeah okay so what happened And suppose your point, okay, suppose this is the curve and your error are here. So, we have to go to the error, sorry, error 0 is this one. So, this is the gradient descent. D loss theta divided by D theta. So, we have to go to the minus of this direction, going in that direction. This is called the gradient descent. And if we are going in that direction. okay we are calling this as a gradient ascent okay and what is the meaning new theta old minus the learning rate d loss divided by the d theta if we are doing the minus this is called as a gradient descent if we are doing the plus this is called as the gradient descent okay that is the difference between this yeah so I'll share this particular slide when you use the gradient descent and gradient descent so you need to decide whether minus say weight update or plus it's up to you it's up to you here is this one error sometimes we need to do the minus sometimes we need to do the plus so it's up to you we need to do i'll give you the real-time example real-time example it is not like this you can choose either we need to classify whether that particular person is having the cancer or not and we got some result okay we got some result so we have some result and your error is like 0.3 okay 0.3 so now we have weight update to update either weight is going in the positive side or the negative side so normally we have 0 okay normally weight we have 0 to definitely the thing is we have plus plus plus करना है और यदि हमारा continuous हमारी error okay continuous पहले बार हमने iteration किया first time we did the iteration and our error is decreasing यदि हमारी error decrease हो रही है that means हमें add ही करते चलना है यदि हमारी error suddenly increase हो गई okay suddenly error increase हो गई that means हमें negative करना चालू करेंगे so it's up to us okay it's up to us we need to take that particular things or not if the learning rate is high then it will subtract learning rate learning rate हमने इतना बड़ा बड़ा step लेता चालू कर दिया तो यहां पर पहुच गए suppose that your error is this one and sorry your error are here and we are getting the zero तो हम बड़ी बड़ी step ले ली और यहां तक यहां तक तो हम gradient को कम कर रहे थे, माइनस कर रहे थे और वी आर रीच वट यहां जैसे ही मिला तो अब हमें एरर को मतलब ग्रेडियन एसेंट यूज करना पड़ जाएगा, नौकी माइनस करना पड़ जाएगा, नौकी माइनस करना पड़ जाएगा, okay, it is like this, okay, minimize where the error is zero yes 100 uh sir sorry in case you already clarified but you can you please suggest some book that where we will go through the foundation yes there will be the one book is there that will be the tom missile okay you can read this particular book or you can take a help from the campus x video okay campus x video or there will be the one more video is there that will be the krish nayak he is the very good guy who will understand who will tell you about this particular thing okay you will definitely get the uh gradient descent and the things in the next upcoming class i guaranteed you okay i guaranteed you okay you will get okay so i'll upload all the data set also okay i'll upload all the data set also because i'll upload i had already uploaded the ipv but i had not uploaded the data set it's my fault i'll upload no issue you will definitely get the thing okay i'll upload everything okay so thank you all thank you all we'll see in the next class next class will be started the deep learning so please we join in the next class okay next saturday okay yeah so thank you so much thank you so much for the connecting. Okay. Thank you.