[00:01:58] Good evening, everybody. I hope I am audible to all. Thank you. Okay. So we are going to start our session. Thank you. Okay. So let me recap the previous class discussion. So if you categorize the machine learning algorithm, it can be supervised. It can be unsupervised. Okay. [00:02:37] So, if you again split the things under the supervised learning, there is one regression, [00:02:45] there is one classification. So, in the last class, we have just [00:02:51] had a discussion on the linear regression. So, this is the part where we have covered in the [00:03:00] last class linear regression. As I promised, I will cover one algorithm machine learning [00:03:07] algorithm under the linear regression and one more algorithm so that you have a proper [00:03:12] exposure of both kind of method regression method and the classic regression method. [00:03:17] So today we are here. I am not audible. Wait. What is the problem? Am I audible? Somebody has [00:03:31] written I am not audible. Please others. Okay. Great. Great. Okay. So we are here today and we [00:03:41] are going to start algorithm, the logistic regression. Okay. The algorithm is the name is [00:03:48] a logistic regression. So don't get confused with this regression word. This is the favorite [00:03:55] question in the interview. So many of the people are confused because the name of the method is [00:04:04] logistic regression so you may think it is a kind of regression method but it's wrong [00:04:11] logistic regression is a classification method okay so this is the topic we are going to start [00:04:19] okay so just uh one couple of example i have given here what kind of classification method [00:04:28] as you know the classification problem where the output variable is a categorical variable [00:04:36] or any category. For example, suppose you want to design a ML based system that will predict [00:04:43] whether a given person will donate or not. So understand this question. Question is about [00:04:49] the person will donate or not. So answer may be like 0 or 1 or yes or no. So it become a [00:04:55] classification method. Based on many properties, these are the input variable. There may be more. [00:05:01] So you are going to predict the person will donate or not based on the age, gender, salary, [00:05:05] and many more things. Another example of classification type of problem is like [00:05:11] in a banking system, you are looking to have a ML model that will scrutinize [00:05:21] the application of the loan based on many parameter and later it will give you an idea [00:05:28] whether the person will later stays, will repay the loan, yes or no. Again, it comes [00:05:34] under the classification problem. [00:05:39] It is about in mechanical or automobile field [00:05:43] where ML model are being used [00:05:46] to predict the machine will fail or not soon. [00:05:49] So it is not going to tell you how long. [00:05:51] It is going to give you the answer yes or no only. [00:05:55] There are many, many, many, many more examples are there. [00:05:59] So just you can go through these notes. [00:06:02] I will upload in the model. [00:06:04] You can refer it. [00:06:06] So, let me explain with the logistic regression through the next example. [00:06:11] As we have done in the linear regression, suppose this is the data set is given to you, [00:06:19] having only the two input feature or input variable age and salary and the third variable [00:06:26] is about the class. [00:06:28] So don't get confused because if you are very new in the field, you may be wondering about [00:06:34] Sir, all the three variables are given, all the three are numerical variable. [00:06:40] But one of the must demand or the classification problem is that [00:06:45] one of the variable or target variable must be a categorical. [00:06:49] So here repay is a categorical variable. [00:06:53] Here 1 and 0 are not typical numeric number. [00:06:57] Here 1 stands for yes and 0 stands for no. [00:07:01] So, you can replace also if you are not comfortable with yes, no, yes, no, yes, no here, okay. [00:07:07] So, please understand this is a categorical variable, repaid, it is not a numerical variable, [00:07:15] okay. So, I will consider 1 or 0 as a class, yes and no, okay. And based on the two variable, [00:07:27] age and salary, I am going to predict the whether person will predict or person will repaid or not, [00:07:32] okay so this i hope this data set is clear to everybody if you have any confusion please write [00:07:39] your doubt on the chat box i will i will take it okay no doubt very good so [00:07:51] ultimate any of the machine learning or deep learning method are what it is only the function [00:08:03] mathematical function where it can take input. So, in this case input is age and salary. [00:08:12] So, this function will take salary and age as an input and it will try to predict [00:08:20] whether it will repay the loan either yes or no. So, what is F? F is any of the machine [00:08:34] learning algorithm or deep learning algorithm in our case f is logistic regression okay there's [00:08:46] your questions sir so classification have only yes and no value okay no uh uh in the classification [00:08:54] uh it's typical a data set is given you like that okay there may be n number of input variable [00:09:05] so that up to this moment is clear there may be n number of input variable like it can be a age [00:09:12] it can be a salary it can be a height it can be a weight many more one variable focus over here [00:09:20] only one variable target variable okay it should be a categorical variable okay in this case [00:09:30] in case of repay the loan, how many classes are there? Only the two classes are there. [00:09:37] It will be yes or it will be either no. Agree? In this case. So, this is we called it binary [00:09:46] classification. Why we call it? Please understand this term because there are only the two classes [00:09:53] either yes or no. We call it binary classification. But there are many other cases. [00:10:00] suppose i want to predict uh uh for example uh happiness happiness okay or any any any of the [00:10:13] feedback feedbacks what it will be there i'm i'm i'm i'm happy okay okay i am neutral neutral [00:10:25] I am okay not happy or very sad like that agree so maybe depend on the application or data set [00:10:40] whatever the target variable is given to you whatever the target variable is given to you [00:10:45] the target variable may have more than two category okay more than two category for example [00:10:52] animal, animal image classification, image classification. The target variable may have a [00:11:05] cat, may have a dog, may have an elephant, may have a cow and many more classes. Okay, so here [00:11:14] if there are two plus classes, two plus classes are given in your problem, we call it multi-class [00:11:24] classification what we call it multi-class classification hope i'm able to clear it it is [00:11:36] not necessary in in classification only the two classes yes or no it depends on the problem it [00:11:42] can have a three can have a five can have a ten can have a hundred of classes okay so [00:11:49] yeah so what i was discussing here yeah so idea is idea is that [00:11:56] look here okay idea is i want a function or ml method where the input variable in this case [00:12:08] having a 2 age and salary will given to the function or the algorithm my expectation is what [00:12:14] your algorithm will give the answer either 1 or 0 it will say yeah it will repay it will not repay [00:12:22] I want that kind of output from the algorithm, okay? That is expectation. [00:12:30] So, you need to understand we don't have such method that directly [00:12:36] taking the input and will give you answer a yes or no, okay? But there are many methods that [00:12:44] that are able to give the response in the term of probability, okay, in the term of probability. [00:12:54] So understand this difference. My expectation was to clear cut answer either 1 and 0, but it is not [00:13:00] possible. So what we have, we have meaning functions that can be worked, that can take the [00:13:06] meaning input and output will be the term of probability, okay. So how I can convert this [00:13:13] probability so that we can predict either of the one class either of the one class okay so [00:13:23] yeah now I have a question for you I have a question for you I want to give you input x [00:13:32] okay x is a set input means x have many feature x1 x2 x3 x4 this is the input i am giving [00:13:50] to a function okay my condition is that it gives you the probability okay what is the range of [00:13:59] probability? Please write on the chat box. Range of probability is 0 to 1. I think everybody agree? [00:14:06] Okay. So, tell me any function and range of x. Okay. So, this range of x is in real life [00:14:13] minus infinity to plus infinity. Agree? So, input of the function here will go from minus infinity [00:14:23] to plus infinity. [00:14:27] So now you give me or suggest any of the function [00:14:33] that can accept input from range minus infinity to plus infinity [00:14:38] and output always be between 0 to 1. [00:14:43] Can you recall any function you have studied in the previous classes [00:14:46] that satisfy this property? Input for the function [00:14:50] range is minus infinity to infinity [00:14:54] and output always be within a 0 to 1. [00:14:58] Please recall [00:14:59] any of the function that satisfy this property. [00:15:03] Anything else? [00:15:09] Yes, Risu is correct. [00:15:12] Sigmoid function. [00:15:18] Sigmoid function. [00:15:20] Correct. [00:15:22] This is the core of [00:15:23] it is a core of [00:15:25] logistic regression. [00:15:31] Logistic regression. [00:15:33] I think [00:15:33] you may also be aware [00:15:37] sigmoid function [00:15:39] also known as a logistic function. [00:15:43] If you are aware, very good. [00:15:47] Otherwise, you should understand [00:15:49] alternate name of the sigmoid function [00:15:52] is the logistic function. [00:15:54] Because of this function, [00:15:56] algorithm name is given logistic regression. [00:15:59] Okay. [00:16:00] Why this name is given? [00:16:02] Now you can recall. [00:16:04] You can connect yourself. [00:16:05] up to this moment things are clear sigmoid function is the core of the logistic regression [00:16:13] and sigmoid function also be known as a logistic function that's why the method name is given [00:16:19] or known as a logistic regression great so this is uh here keep the discussion very simple [00:16:33] this is the logistic regression function or sigmoid function it is a constant this is the [00:16:43] constant this is the constant where the variable that value you can change I think everybody agree [00:16:48] this is the formula of logistic function where everything are here are constant you can change [00:16:59] the value except x what are the x these are the input variable these are the input variable [00:17:10] slowly slowly i will pick layer by layer i will pick the layer and expand one by one [00:17:18] so this is the logistic function and here everything is constant except x so what do [00:17:26] do you mean by x is an input variables okay so how to keep the input variable here okay so now [00:17:37] the next part of the logistic regression is that yeah this is the logistic function yes yes yes [00:17:47] here this is the line equation this is the line am i audible now now yeah great thank you [00:18:47] okay so you got it what i was discussing it is the sigmoid function where everything is a constant [00:18:58] except yeah thank you except x so what is the x x are the input variable but how you can keep the [00:19:07] input variable here in the form of line equation okay so we have seen in the linear regression [00:19:14] you can keep the equation of the line [00:19:17] by accommodating [00:19:19] many of the input variables. [00:19:22] So you can write this sigmoid function [00:19:23] like 1 upon 1 plus x [00:19:25] e to the power minus theta 0 plus [00:19:27] theta 1 x1 plus theta 2 x2 [00:19:29] like that. So what is this? [00:19:33] Are you able to recognize this part? [00:19:36] What is this? [00:19:40] Okay, these are the weight. [00:19:41] This is a line equation. [00:19:45] Or it is a linear regression [00:19:47] in a very [00:19:48] very general term if I talk about the linear regression. I think everybody agree or not? [00:19:58] These are the input features or input variables how I have arranged in the form of linear line [00:20:05] or linear regression. Now you have a proper understanding why we call this algorithm [00:20:14] logistic regression it's very favorite question during the interview okay is it clear logistic [00:20:24] means because the logistic function has been used regression means we are ultimate drawing a line [00:20:31] in the logistic regression also we will draw this line i will find the best fit line so because of [00:20:37] this property we call this method name is a logistic regression these two terms are clear [00:20:42] to everybody great yeah so this slide is uh i have explained uh wait yeah so what is objective [00:21:16] okay i'm going to repeat here again okay yeah please focus here i am going to repeat this part [00:21:24] so there are two questions who are there the the name of the method we are discussing is [00:21:29] the logistic regression so you need to understand why this name is given so two terms are there [00:21:35] logistic and the regression logistic come from where because it use the logistic function [00:21:43] sigmoid function and logistic function both are same okay we also call sigmoid function as a [00:21:48] logistic function and we need to keep all the input variable together and in the in the sigmoid [00:21:59] function definition, only this part is there that is a variable. All the other part are the constant. [00:22:08] So, how to keep the variable in the logistic function? In the form of linear line. [00:22:13] And this is a linear line we have seen in the last class. It looks like a regression problem. [00:22:19] Ultimately, we are drawing a line. So, this is the property that we have any heritage from the [00:22:26] regression that's why the function name or method name is given the logistic regression okay [00:22:36] it is clear now great so moving ahead what is the algorithm this is the algorithm [00:22:49] in our case there are two input variable if you are able to see it age and salary you need to [00:22:58] feed the data to this algorithm. And once training is over, what happens? Recall the previous class [00:23:04] discussion. Once training is over, we have a best fit line. And accordingly, we estimate [00:23:10] the value of all these coefficients. Suppose the training is over with the logistic regression [00:23:18] and the final model we got it, this one, where theta 0 is 5, theta 1 is 8, and theta 2 is 3. [00:23:26] so don't stick how why 5 8 and 3 as we know it depend on the best fit line wherever we got the [00:23:35] best fit line accordingly the coefficient will be finalized okay is it clear okay so how we are [00:23:50] going to use it? Suppose this is the final model. 1 plus it will be power 8 plus 5 is [00:24:07] plus 3 salary. Okay. So, suppose this is your model. This is your model. How to use? Question [00:24:22] is how to use in the real life. Real life. Okay. So, in the real life what happen? We need to give [00:24:31] the input variable. Agree? What are the input variable in our case? We have to give the age [00:24:37] plus we have to give the salary. I think everybody agree. Suppose age is 29, salary is 2000 for [00:24:46] example. Agree? So, what happened? We will put this value in this model. What was the model? 8 [00:24:55] plus 5 multiply this age. 29 plus 3 multiply with 2000. Agree? You solve it. Suppose, suppose [00:25:17] this is something delta. [00:25:24] You solve it and this is delta. [00:25:26] So if you put any of the value [00:25:29] delta ideally can be ranged from [00:25:32] minus infinity to plus infinity. [00:25:36] But the final output will be between 0 to 1. [00:25:40] I think everybody agree? [00:25:44] I am slowly slowly covering every part [00:25:46] every layer of the logistic realization. [00:25:49] now assume that this output is given 0.75 okay yes yes or during the training we have to estimate [00:26:11] all the value of b0 b1 b2 once training is over you can use that function for the prediction [00:26:17] purpose like i am explaining okay sara okay now question is suppose this this function or method [00:26:31] have predicted 0.5 or you can say the 75 percent agree now the question is here what will be the [00:26:40] prediction yes or no 10 because there were only two options either you will the person will pay [00:26:48] the loan yes otherwise person will not repay the loan so what will be the answer depend on the [00:27:01] decision boundary based on the threshold yeah okay okay case 2 suppose output probability [00:27:14] equal to 0.51 here 51 percent then what is the answer yes or no it will repay yes or no [00:27:24] answer is yes. [00:27:27] Agree. [00:27:30] I am very happy to see [00:27:32] your answer. Case 3. [00:27:34] If probability is [00:27:35] 50% then [00:27:37] case 4. [00:27:43] If the probability is [00:27:45] 45% then [00:27:47] okay. People are writing no. [00:28:05] No Amit. [00:28:07] Amit you are wrong. [00:28:09] The problem is [00:28:10] if your problem is classification problem [00:28:13] you cannot use the linear regression. [00:28:15] okay i mean the fundamental question is here it is not your choice if the problem is the [00:28:22] classification problem it is impossible to use the linear regression okay understand the fundamental [00:28:31] okay now i got the same there is a concept of threshold okay that is a user defined understand [00:28:44] that is a user defined everything please user defined that is a user defined by default value [00:28:54] is what by default value is 0.5 so by default i am explaining by default if probability is greater [00:29:06] than is equal to 0.5 it will go to the class yes okay else it will go to the class no [00:29:15] concept is clear by default setting okay now as it is a user defined you can change it [00:29:27] okay you can change it user may redefine it redefine is as if property is greater than [00:29:45] 0.6 then yes class and else no class okay it is possible so please note it down [00:29:57] what is the reasoning behind it and when we need to increase the threshold [00:30:02] i will discuss during the deep learning if i missed it in the later stage you please [00:30:08] recall at that time. [00:30:12] It's very important [00:30:13] discussion how to set [00:30:15] and what are the mechanism [00:30:16] and what is the concept behind [00:30:19] increasing and decreasing the value of [00:30:21] trace hold. But it happens. [00:30:23] Okay. [00:30:25] Great. [00:30:27] Yeah. So, moving ahead, [00:30:29] things are clear. [00:30:31] Okay. So, this is the turn. [00:30:32] Technically, this line equation [00:30:35] with respect to the logistic regression, [00:30:37] we call it the logit. [00:30:38] So, you may be wondering if you refer any of the book, they use such terms. [00:30:43] So, just understand this line equation with respect to the logistic regression, we call [00:30:49] it logit, just termological introduction. [00:31:03] Okay, so what is the next? [00:31:05] Yeah, so that was the idea. [00:31:09] Now, what happened during the training? [00:31:12] Okay, what happened during the training? [00:31:14] So, let's have a look again. [00:31:16] this is the data set we have considered having the three variable two are the input variable [00:31:23] age and salary and this is the target variable one and zero are the categorical classes okay [00:31:29] so yeah so let me explain the training training intuition behind the training understand is very [00:31:39] interesting intuition or concept behind training it's very interesting so suppose this is the your [00:32:00] linear regression or logistic regression method okay so like theta 0 plus theta 1 age that is [00:32:13] first first step theta to salary. Up to this moment things are clear. So what is the first step? [00:32:22] In any of the DLML, initialize any, initialize the coefficient or weight. Agree? [00:32:35] Agree or not? Up to this moment. It is a fundamental rule. Don't worry about that. [00:32:43] whether it is a linear regression, logistic, deep learning, LLM or whatever there are. [00:32:49] So, suppose what I have done, you tell me the random value or how to initialize random. [00:32:59] So, these are the constant. I cannot touch. What I will do? Theta 0. You tell me any other random [00:33:07] value. It can be anything. Suppose it is 5. Okay. Random value 10. To understand the concept, [00:33:16] don't go with the detailing and suppose 7. Okay. Okay. Yeah. Now visualize this is the data set. [00:33:32] This is the data set. Okay. These are the data point of no classes. So x means [00:33:41] no class, round means yes class. So these are the data point of the no classes, [00:33:52] these are the data point of positive classes, okay. So this is simple, you can plot the data set [00:34:06] like here, wherever the class is one, you can represent as a as a as a zero or as a round [00:34:14] shape where wherever the class are zero you can represent as a cross or you can give a different [00:34:21] color. In this ppt all these two type of observations were visualized in a different color [00:34:29] but since the color is not very much visible to us that's why I am presenting these observations [00:34:36] of these two different classes with the cross and zero. Up to this moment things are [00:34:43] clear? You assume like this. Yeah. You assume like this. Okay. Simple x-axis and y-axis. Simple [00:34:55] two dimensions. Okay. So, these are the observations. Amit, we are going to visualize in the plot [00:35:07] where observations of the negative or no classes are represented through the cross and observations [00:35:15] of the positive or yes classes are represented with the zero. Okay? Like this. [00:35:23] This is the basic of plotting the data. So, this is the first data. It will be represent as a zero [00:35:30] class, zero class. Oh, sorry. This is zero, zero, zero, zero. This is for cross, cross, cross, cross, [00:35:35] cross. Okay? Okay? What repaid means? I think you joined late. Am I correct? [00:35:45] from the beginning i am discussing multiple time what is the meaning of repaid repaid means class [00:35:52] variable okay it is yes no yes no kind of things person is going to pay the loan yes no yes no yes [00:35:59] no okay yeah this diagram is clear to everybody it is very critical discussion we are going to [00:36:07] have now okay up to this moment things are clear please write on the chat box no it is not [00:36:20] necessarily g1 it can be negative or positive okay g1 and everybody those weights and coefficient [00:36:30] are random value or in the real life it may be negative may be positive okay this is the 3d [00:36:40] diagram. So consider it is not or consider it is x and y. Okay, so this is x and y. Assume that [00:36:47] this is the age. Okay, consider that this is the salary and these are the class. These are the [00:36:56] class. You can represent in the different color also. Okay, so in this PPT, the observations of [00:37:05] both the classes are presented in the different color but that are not clearly visible. [00:37:10] okay yes yes because if there are many variable you can think about the 3d or 4d or 5d [00:37:20] visual aspect okay is it clear up to this moment now great great great so what is this now I have [00:37:41] a question okay what is this this is a line I think everybody agree I think everybody agree [00:37:48] this is the random line okay to training first step understand i am explaining the training part [00:37:56] what is happening inside the training training first step in the first step random [00:38:06] coefficient are in slice so this this can be a this line i can assume [00:38:12] okay i am assuming this is the line it can be anything just understand the concept okay this [00:38:20] is the line you have drawn because b0, b1, b2 are you have taken randomly. So this is the b0, b1, [00:38:27] b2 with respect to this line. Okay. Is it clear? You have to keep on writing because it is very [00:38:42] critical part. That's why I'm going very slowly. Okay. So look, this is, you look here, this is [00:38:55] clear to everybody. This part who is asking the question particularly, this part is clear. [00:39:02] okay yes so this is a random line because b0 b1 and b2 we have taken randomly any doubt [00:39:14] i think people who are joining in middle they have a lot of confusion okay or you might have [00:39:21] missed the previous class about the linear regression is typical linear regression [00:39:25] okay so what is this it is line or not you just tell me so suppose this is this line [00:39:33] any question first random line you have drawn a random line okay now tell me here idea is what [00:39:52] idea understand the idea very interesting idea idea is that the whole data the whole data [00:40:02] line divide into the two part. What is the first part or second part? You have [00:40:14] drawn a random line in the logistic regression. First step, what this line [00:40:19] does? The whole dataset it divide into the two parts, upper part or lower part. [00:40:25] Okay and line will say this is the yes, this is the no class, [00:40:35] And line will say, these are the ES class. [00:40:39] Okay. [00:40:39] If data points are above the line, the line will predict all those data points as a, they [00:40:47] are not going to repay the loan. [00:40:51] All the data points that are below the line, it will predict what they are going to pay [00:40:57] the loan. [00:41:00] Okay. [00:41:00] if you fit if you if you send this data point to the logistic regression model the logistic [00:41:09] regression model will predict yeah they are going to repay the loan they are going to repay the [00:41:13] loan because they are below the line if any data point that are above the line line will directly [00:41:19] predict no zero class okay is it clear to everybody but you might have observed there is a [00:41:35] issue these are the data point that should be in the yes class okay but because the data point [00:41:46] lies above the line my line is misclassified them so this this will be the misclassification this [00:41:55] will be the misclassification this will be the misclassification this will be the misclassification [00:41:59] this will be the misclassification this will be misclassified and that means there may be x here [00:42:04] may be possible so this is again a misclassification because it will this this is this is the data [00:42:12] point that is not repaid but it is below the line so my my model will predict this person is going [00:42:19] to repay the norm so vice versa okay so these all are the misclassification okay up to this moment [00:42:28] things are clear great now somebody asked data point are on the line data point are on the line [00:42:47] okay on the line means probability is 0.5 percent so it up to you which function you have defined [00:42:54] okay if threshold value is 0.5 so data point on the line or above the line may go to the class [00:43:02] a otherwise class b so all the data point the probability will be less than 0.5 logic is here [00:43:10] the probability of those point will be greater than or equal to 0.5 okay slowly slowly i am [00:43:20] touching all the important part of the logistic equation so ultimate line will give you the [00:43:26] probability i talk about yes yes satya but this line this line has placed on the right right [00:43:46] right position or not you tell me i have a simple question so this first line i have placed over [00:43:53] there it is it it it is the best position or not so what do you need you need to shift the line [00:44:02] above bit more so it improves the performance because here how many misclassification okay if [00:44:09] I ask the question at this case how many misclassifications are there you tell me you [00:44:17] count 1 2 3 4 5 6 7 and 8 why you are not counting this this is also misclassification [00:44:28] It is 8. Everybody agree? Now, I updated the weight. That is a part of training. I updated [00:44:49] the weight or coefficient and through gradient descent, I will cover in deep learning the [00:44:57] gradient that I also talked about in the previous class. So, it updates the weight. Update the [00:45:03] weight means what? We have a now new line. Got it? This concept is clear. Update the [00:45:11] weight means what? We are going to change this 5 with some new number, 10 with new number, [00:45:16] 7 with new number. Ultimate updating the weight means you are drawing on the new line. Okay? [00:45:24] okay so suppose that was the line 1 now we have a line 2 suppose [00:45:37] suppose we have a line 2 this line 2 so it is a misclassification with respect to the line 1 [00:45:47] Now you tell me the misclassification with respect to the line 2. [00:45:52] How many misclassifications are there? [00:45:54] You count. [00:46:04] Only 4. [00:46:05] Yes, correct. [00:46:06] This, this, this or this. [00:46:12] So, now we have a better model or not? [00:46:19] Great. [00:46:20] So, discussion is over. [00:46:22] You need to repeat this process until tell me. [00:46:28] Repeat this process. [00:46:30] You need to go for training, multiple iteration, until tell me when you are going to stop until, until get the best line, best line. [00:46:51] Now, a terminological introduction, please, everybody in logistic regression, we don't call it line. [00:46:59] What we call it? Any idea? We don't call it line. [00:47:05] no logical mathematical part, no sigmoid is a function is not a curve, no [00:47:13] we call it decision boundary. A very suitable word or term you're supposed to [00:47:26] use. It is a decision boundary, yes, because in making the decisions, this is [00:47:32] boundary, above the boundary is something else, below the boundary is something else. [00:47:37] So, this is a decision bounding. [00:47:39] Better word is to use the decision bounding. [00:47:47] This line is drawn with axis, both axis. [00:47:51] So, because age and salary, you see over here, both the axis I have taken. [00:47:59] Okay, because? [00:48:03] So, this is a very simple question. [00:48:04] Both the age and salary I have taken. [00:48:07] That's why both the axis. [00:48:09] So, ultimate, this decision bound is what? [00:48:13] It is a classifier. [00:48:16] This is a classifier. Mathematically, it is a curve or line. But in machine learning, what we [00:48:26] call? We call it either decision binding or classifier. Okay. Up to this moment, I hope [00:48:36] I am able to make it clear to everybody. So what do you mean by the best boundary or best line? [00:48:44] The question is unanswered. What is the best boundary? You define it, please. How do you [00:48:54] know it is the best yes Rishu you are correct features variable both are same okay Rishu [00:49:08] okay that is a good question Pritam how to calculate the error we are not going to use [00:49:17] MSE and MAE that is a great question Pritam I will answer during the deep learning okay [00:49:27] indirectly you are you are correct so you may be wondering about like it's very good discussion [00:49:35] In the linear regression, you can say sum of square error is a way to calculate the error, mean absolute error, okay, something, something, something. [00:49:45] But in the logistic regression, we cannot use it, we cannot use it, okay, okay. [00:49:55] So, in the logistic regression, it will be part of deep learning, but I am going to answer it. [00:50:00] We use the concept of the cross entropy, but we are going to use the cross entropy, okay. [00:50:08] and I will answer in during the deep learning. Okay, when we covered the deep learning method, [00:50:15] I will answer that part. Okay, R2 is a part of here, linear regression. Here we use R square [00:50:27] or adjusted R square. All those are the matrix we use in the linear regression, not logistic. [00:50:35] okay okay yeah but conceptually when we are going to stop when we stop training [00:50:54] in in logistic regression i can give the idea answer is here answer may be like that [00:51:06] answer may be like that. When we stop improving, when we stop improving the performance. Agree? [00:51:21] Performance means in simple way you can consider as an accuracy. Accuracy means what? Number of [00:51:29] observations you have classified correctly or error rate. Accuracy if you don't want to use [00:51:36] you can use the error rate. Error rate means what? Means number of misclassification. [00:51:45] Number of misclassification. Agree? So intuition says that in this diagram earlier number of [00:51:57] misclassification was 8 then in the next sequence misclassification become 4 if you anyhow drawing [00:52:06] repeatedly multiple line beyond some moment you cannot reduce the misclassification [00:52:12] it's where rarely happen you draw a line that will 100% classify 100% accuracy classify both [00:52:22] kind of observation. It is very [00:52:24] rare. Okay. There [00:52:26] will be some error or [00:52:28] overlapping or misclassification. [00:52:30] But beyond, sometimes you cannot improve [00:52:32] it. At that time [00:52:34] you need to stop. [00:52:41] Okay. So, actually [00:52:42] the question you have asked about [00:52:45] R square, the answer is no. [00:52:47] Okay. Both are different. [00:52:49] Actually, got [00:52:51] it? About the [00:52:52] question R square in the linear regression [00:52:55] is equivalent to the cross entropy. [00:52:56] answer is no. Okay. No, 100% [00:53:06] it is not possible. So, in this case, you cannot draw [00:53:10] a line that can classify [00:53:14] perfectly all the data. It is not linearly separable. So, there is a [00:53:18] concept of linearly [00:53:21] linearly separable or [00:53:33] inseparable. Okay. These are the two kind of [00:53:40] problems are given or data set. If you can split through the linear line or classify the data set [00:53:49] through the linear line, we call it linearly separable, otherwise inseparable. These two [00:53:56] terms are clear to everybody. Suppose, for example, consider this diagram. Can you draw a line that [00:54:17] can separate 0 and star, case 1, through a line. Can you do it? And here, here, case 2, yeah. So, [00:54:38] it is a linearly separable. It is not linearly separable. So, luckily, if you have a such kind [00:54:46] of data set, you can achieve that you can achieve 100% accuracy, okay. But that is in theory, [00:54:55] practically it is not possible because such data sets are not available okay so that part is over [00:55:18] yeah so i have covered that thing everybody everything i have covered it yeah this is [00:55:23] about the boundary i had a discussion about it yeah so uh one important part again if you increase [00:55:32] more input variable look at the screen data set is changed now we have a three input variable like [00:55:39] age, salary, salary of the spouse, then class variable 1 and 0. So like we have seen in this [00:55:50] case what happened? We are not going to draw a line as a boundary. We are going to draw a plane [00:55:56] or hyperplane as a boundary. Ultimate you need to visualize the things into the 2D, 3D or ND. [00:56:03] so you want to separate [00:56:05] the 3D items [00:56:07] so these are not possible through the line [00:56:09] you need to draw a plane [00:56:11] simple idea nothing else [00:56:12] nothing new [00:56:14] so Krishna it is clear [00:56:19] your question is here [00:56:20] so now you have to find the plane not a line [00:56:25] so [00:56:41] yeah [00:56:42] extension or variant [00:56:46] of the logistic regression is [00:56:48] now we are going to start [00:56:49] polynomial logistic regression. Multiple plane. So, it's a simple mathematics plane or multiple [00:57:00] hyperplane like terminally classes, multi-class classification like that. Okay, hyperplane or [00:57:08] plane. In 3D, we normally call it plane. If there are more Ds, we call it hyperplane. Just names [00:57:14] are there. So, just see on the screen, what do you mean by the polynomial logistic regression? [00:57:20] like you have already been studied the polynomial regression so you may recall that discussion [00:57:29] about the polynomial regression and try to connect here how we can apply this concept [00:57:36] in polynomial logistic regression power is more than one okay there's a mathematical [00:57:43] answer actually with respect to the logistic regression you try to answer it i'm waiting [00:58:00] for your answer what is the idea intuition about the polynomial logistic [00:58:06] revision a chair no no no yes agreed but what is intuition think about yes [00:58:27] somehow this might have returned the correct answer yes yeah it's not a line [00:58:36] now. Yes, to solve the answer correctly. Yes, so just intuition I am going to explain otherwise [00:58:50] things are same. Consider this case. Okay, consider this case only. So suppose I am able to draw this [00:59:00] plane. Suppose I am able to draw this plane. Now data points that are inside [00:59:10] this plane are class X. Outside data points belong to the class Y. Got it? Yes, [00:59:26] yes, yes, yes. Yes, Pritam, it is all about the feature engineering. Pritam, you [00:59:32] are correct. Feature engineering is a very vast area. [00:59:37] Unfortunately, it is a part of typical machine learning and you must go through it. [00:59:44] So we don't have that time to discuss about the future engineering but Tritam, your question [00:59:50] answer is yes. [00:59:56] Is it clear? [00:59:57] Just understand the intuition is very good. [00:59:59] Mathematically, during the training everything will happen, you don't need to worry about [01:00:03] that. [01:00:04] So intuition is what? [01:00:06] Sometime, we cannot split or we cannot draw a straight boundary to separate the data points. [01:00:15] So what we have to do? [01:00:17] We need to replace the linear line through any kind of curve. [01:00:22] It can be anything. [01:00:23] It can be anything. [01:00:25] So this is called polynomial logistic regression. [01:00:31] Okay. [01:00:32] Suppose this is the data set is given to you. [01:00:35] Weight and BP, blood pressure of patients and whether they suffer from a heart stroke or not. [01:00:45] So again, it is a class variable, yes, no. [01:00:48] So if you draw these data points. [01:00:50] So again, these are not visible because of the color. [01:00:54] Ultimate, they are not linearly separable. [01:00:57] So we need to draw such kind of boundary. [01:01:00] If during the training, it is not easy to find [01:01:03] because this boundary means everything. [01:01:07] These are the only the curve fitting. [01:01:09] Curve fitting means what? [01:01:10] Look, theta 1, theta 2, weight, BP square, weight square, under root BP. [01:01:18] And we don't know how to find out this curve properly. [01:01:23] So, a lot of hit and try, hit and try, hit and try we need to draw. [01:01:27] Okay. [01:01:36] Okay, Kaustub somehow you are correct. The intuition of the logistic regression we have given. [01:01:49] Instead of fitting a line or straight decision boundary, we try to fit the [01:01:59] polynomial curve other than the line. So, it may offer a better performance. [01:02:05] The function, in the linear regression function can be continuous, can be both. [01:02:40] So that is a very good question. [01:02:43] What happened? [01:02:44] That is a tough question. [01:02:47] Suppose as an optimizer, you are using the gradient descent. [01:02:51] You are using the gradient, very tough question, gradient descent. [01:02:57] whatever the function you are using, okay. Sachin, I am asking your question. It should be continuous. [01:03:04] It should be continuous, okay. And the function is continuous. It will give you always, always [01:03:13] better performance, okay. Better performance, okay. Non-continuous function, you cannot apply [01:03:23] the optimizer like a gradient design. Yes. Yes, Satya, you are correct. Now you are understanding [01:03:32] the data science now. I'm very happy to see such kind of questions. Please, Satya, that is the [01:03:39] complexity and difficulty of the data science or machine learning. Answer not straightforward. [01:03:45] They are not conventional way of solving the problem. A lot of variability, a lot of hit and [01:03:52] right. A lot of sensitivity [01:03:54] are there. If you increase [01:03:56] the more training data after [01:03:58] 10 days, your model will be different. [01:04:00] You need to retrain it. [01:04:02] That's why we call model [01:04:04] is learning day by day, day by day. [01:04:06] Because in the first step, [01:04:09] so, Satya [01:04:10] have pointed out a [01:04:12] very good discussion. Suppose [01:04:14] this is the training data. [01:04:16] Training data 1. [01:04:18] You have trained the model M1. [01:04:21] Okay? [01:04:22] Now, you have another training data, T1 plus. [01:04:29] You need to again train the model that will be M dash 1. [01:04:34] It will be different from the M1. [01:04:36] Yes, it is correct. [01:04:38] The moment you add more training data or reduce the training data, [01:04:43] if you train the model, it will have again different model. [01:04:47] Yes, answer is. [01:04:50] So, what is the best one? [01:04:51] We can't say. [01:04:52] every time we need to hit and try see the features and many many many many things okay [01:05:01] so yeah this thing is over up to this moment Akas have a question so does the model retain [01:05:15] the memory after it is retrained no it once retraining means what Akas you are updating [01:05:24] the weights okay once weights are updated everything is gone previous things are gone [01:05:29] hope things are clear [01:05:34] we are not going to [01:05:37] if you are going to keep the copy of the [01:05:39] two different models it will be there [01:05:40] but same model you are training means you are [01:05:43] updating the weight [01:05:44] no it will lose [01:05:54] because you are going to [01:05:56] retrain it [01:05:57] don't confuse with the previous or new data [01:06:00] every time you are retaining means new [01:06:02] data new thing will happen [01:06:03] new parameter [01:06:06] new weights everything will be the new [01:06:08] okay so now yeah so these things are over polynomial logistic regression cutoff [01:06:20] very briefly i had touched upon the cutoff and if time permit what are the idea and concept [01:06:30] based on that either you should increase the cutoff or decrease the cutoff if time permit [01:06:37] we will discuss during the deep learning. [01:06:40] Okay. [01:06:44] We can customize everything. [01:06:46] Jiten, everything, any machine learning model [01:06:49] you can customize. [01:06:54] Cross validation, discuss later. [01:06:56] It's checking or evaluating the model. [01:06:59] It's a different concept. [01:07:04] Yes. [01:07:06] It performed well in unseen data. [01:07:08] Yes, agree. [01:07:09] So if more data comes in the later, [01:07:11] should we expect that model to perform well [01:07:13] on that new data? [01:07:14] Yes, we can expect Pritam, but things are not happening in the real life. [01:07:20] If the new data comes from the same distribution, answer will be yes, otherwise no. [01:07:27] Okay, Pritam. [01:07:31] Again, very tough question. [01:07:34] Yes, Pritam. [01:07:35] Okay, I am discussing about the Pritam part. [01:07:37] Everybody else, please focus over there. [01:07:41] What Pritam is asking. [01:07:43] Suppose this is the data set. [01:07:46] I have trained it. [01:07:48] This is the testing data. [01:07:51] Okay. [01:07:52] This is the training data. [01:07:54] Very good question. [01:07:55] This is the training data. [01:07:58] I have trained the model here. [01:08:01] This is model 1. [01:08:03] I have checked the performance in unseen data. [01:08:06] Testing data means unseen data. [01:08:11] Okay. [01:08:12] Unseen data. [01:08:14] If the testing is okay, then we have finalized model M1. [01:08:20] And in the real life, this is a real life data coming in the future. [01:08:26] Okay, I'm using the model M1. [01:08:29] Okay, Pritam, that is your question. [01:08:32] So answer is that if the property of this data, new data, this property, statistical [01:08:40] property I am talking about. The statistical property is same as the training data or earlier [01:08:52] data. Statistical property is same. Then your model will work fine. No issue at all. But in future [01:09:01] the patterns are getting changed and here statistical property is different. Pattern is [01:09:08] different now pattern is different statistical property is property is now different okay [01:09:18] then same model m1 fail agree or not everybody else what the very very intuition and very high [01:09:32] level understanding or discussion i have made over here it may not be right time but i tried it [01:09:37] okay so that you need to confirm in the later stage patterns relationship like buying pattern [01:09:46] may be changing after some time so buying pattern are changing previous model if you are using it [01:09:52] will fail yeah so this is the area we call it robust how to change the how to change the model [01:10:01] is robust or not that is not part of our course at all how to confirm model is robust if your [01:10:10] model work fine both the cases your model is robust otherwise your model is not robust [01:10:14] okay statistical property means relationship among the data items okay how the data items [01:10:27] are related to each other relationship among the variables okay akas there may be n number [01:10:35] of input variables, how those variables are related to each other. That pattern should be [01:10:40] same then your model will continue otherwise will differ. [01:10:45] Okay actually, what happened to the output of the logistic function when the input [01:10:56] oh I missed that wait one minute okay what happened to what happened to the output of [01:11:21] the logistic function when the input become very large. I don't know it cannot be larger [01:11:28] than the infinity because I have already covered. If you put in the line, logistic regression can [01:11:35] take input value from minus infinity to plus infinity. How decide whether to use the least [01:11:41] linear logistic or polynomial log? Hit and try. Suraj's answer is if you plot, [01:11:48] if you plot such kind of variables and try to find out the relationship, [01:11:55] so you can just [01:11:57] if you have a domain knowledge you can have [01:11:59] an idea of whether the polynomial [01:12:01] will work or the linear will work. It comes [01:12:03] with the experience otherwise hit and try. [01:12:06] Okay. [01:12:10] Okay. So I want to end [01:12:12] this [01:12:13] discussion to [01:12:15] by covering [01:12:18] the topic confusion matrix. [01:12:21] Okay. So give me some time here. [01:12:23] Somebody have written already [01:12:24] a confusion matrix. [01:12:25] Please everybody focus again on the screen. I am starting about the confusion matrix. What it is? [01:12:36] It is very interesting. So, I will explain with respect to the binary classification. You can [01:12:41] extend it to any kind of multi-class classification. So, understanding the concept of confusion [01:12:47] matrix with binary classification is very important. So, why it is used to evaluate? [01:12:55] First answer, to evaluate the performance of classifier, any classifier in the world, [01:13:06] not logistic regression, any classifier. Either it is from deep learning, machine learning, [01:13:12] anything, anything. So it is not part of logistic relation, but it used to evaluate any kind of [01:13:20] classifier. So it is a confusion matrix. What it is? So confusion matrix, what we does? We create [01:13:29] this table, understand this table carefully. This table, one side we have a predicted class means [01:13:38] these are the answer or prediction made by your trained model. Another side are the answer from [01:13:47] the data set or ground truth or actual class. Actual class means what is the correct answer? [01:13:56] Predictive class means prediction made by your model. These two terms are clear or not? [01:14:02] vertically, you can change here and there, doesn't make any difference. One side talking about the [01:14:09] answer given by your model and another side is about answer from the data set or correct answer. [01:14:16] Okay. Is it clear these two terms? Okay. So, suppose it is a binary classification. So, [01:14:29] there will be two answers given by the predicted model. So, the model either answer will be [01:14:35] yes or either answer will be no. So, suppose it is a class 1 or it is a class 0. So, your model [01:14:43] will give response in the term of either yes or no or you can consider it is a 1 and 0. [01:14:52] Similarly, the correct answer also in the same form, correct answer of a given observation will [01:14:58] be either yes or no. Is it clear to everybody? These two terms again, yes, no and yes, no means [01:15:06] what? Great. So, what is the true positive? Focus over here. Please everybody, please focus over [01:15:23] here. These are the numbers, number of observation. Please understand every word I am using. [01:15:31] These four sections, true positive, false negative, false positive, true negatives are [01:15:38] the numbers. [01:15:40] There will be some numeric number. [01:15:41] Okay. [01:15:42] Is it clear? [01:15:42] For example, in the real life, it will look like that. [01:15:46] It will look like this. [01:15:48] Predicted value, yes or no. [01:15:52] Actual value, yes or no. [01:15:55] These four spaces, we have only the numbers. [01:15:58] Okay. [01:15:58] Any numbers. [01:15:59] anything will be there numeric value okay so interpretation of those numeric value [01:16:05] please be with me here so if these are the number true positive are the all those numbers [01:16:14] where your model is predicting those observation as a class yes but they are actually [01:16:22] from the class yes. So, this is called true positive. True means what? Positive means [01:16:31] my model is keeping them as a positive class, yes class or they are true. So, it is a number [01:16:38] of observations that comes from the correct classification that their real class was yes [01:16:43] and my model also predicting them as a yes class. Okay, yes means any class one or zero like that. [01:16:49] okay go to the diagonally green color green color means correct classification [01:16:56] so this true negative are those number of observations that was that was that were [01:17:03] really in the negative class or no class my model correctly classified them as a no class [01:17:10] or negative class so it is again a correct classification okay please look over here [01:17:16] focus on the green color part only [01:17:18] the true positive and the true negative [01:17:20] interpretation is clear to everybody [01:17:22] think about the opposite now [01:17:32] I am giving you [01:17:34] two minutes think about the [01:17:36] false negative and false positive [01:17:38] I am giving you two minutes [01:17:49] to find out the interpretation of [01:17:51] false negative and false positive [01:17:52] that is the wrong prediction that's okay [01:17:54] but what is the meaning [01:17:55] yeah so false negative means what [01:18:16] yes very good [01:18:18] very good I am happy to see [01:18:20] Yes. [01:18:21] Great. [01:18:23] They are actually a part of yes class. [01:18:27] But my model is saying no, no, no. [01:18:28] They are part of negative class. [01:18:30] So that's why we called it false negative. [01:18:35] Similarly, false positive means those observations that were actually in the negative class or no class. [01:18:42] But my mistaken, my model predicted them as a class. [01:18:45] Yes. [01:18:48] Great, great, great, great. [01:19:00] Depend on application satya. [01:19:03] Again, medical applications or inbox classification, [01:19:06] it depends on what class according to you are the positive class. [01:19:11] Straightforward, you cannot say it's dangerous. [01:19:14] No. [01:19:16] In case of disease plus, which is the positive class? [01:19:20] If you change the positive class to the negative class, [01:19:23] the interpretation will be different. [01:19:27] Okay, so this is the confusion matrix [01:19:29] and through the confusion matrix, [01:19:32] you can you can measure many other performance measure like a recall, like a precision, like a [01:19:40] specificity, like accuracy and AUC curve many more. So today I will cover only accuracy, how to [01:19:50] calculate the accuracy. So interpretation of true positive, it is written over here. I will upload [01:19:55] these nodes. True negative, I will upload here. And one important part, the famous, another famous [01:20:01] term is type 1 error and type 2 error okay they are very heavily used in data science [01:20:06] so type 1 error means false positive false positive means this type 1 error and and and [01:20:18] uh yeah false negative type 2 error so don't confuse if somebody will ask about what do you [01:20:24] know about the type 1 error nothing but it about false positives are the type 1 error [01:20:30] False, negative are the type 2 error. [01:20:33] Okay, so these two new terms we have learned today. [01:20:36] Type 1 error and the type 2 error. [01:20:42] Now, what is the formula of accuracy? [01:20:49] You need to find out those correct classifications. [01:20:54] True positive and true negative. [01:20:57] Slash, divide by all the predictions. [01:21:01] So, if you have a confusion matrix, easily you can calculate the accuracy. [01:21:06] Okay. Yes. Great. You see, you have correctly given the answer. Very good. So, you see over [01:21:28] here, in this case, how to calculate the accuracy? 100 plus 50, 100 plus 50 divided by all the [01:21:37] observations, 165. Misclassification rate means 1 minus accuracy you can do or either, [01:21:45] these are the misclassification 10 plus 5 10 plus 5 divided by all the observations [01:21:50] okay similarly there are many more precision recall if you have time please go through them [01:22:00] otherwise if time permit i will i will pick during the deep learning but i suggest don't [01:22:06] wait for that time precision recall or other part please go through it at your own level [01:22:13] okay okay if you have a still some questions i can take up otherwise we are going to end the class [01:22:35] it was good to have a look on the logistic regression it was interesting or not [01:22:41] okay so next class onward we will start deep learning fundamental of machine learning is over [01:23:09] over as i promised deep learning or neural network or neural network next class okay [01:23:24] assignment 1 the question will be based on [01:23:32] the topic I have covered. The simple answer. [01:23:40] Assignment 1 there is no slavers. Whatever I have covered [01:23:42] it will be the part of question. Is there a deforest? [01:23:45] No, no, no. Acche no deforest [01:23:48] not KNNN. Nothing else because they all [01:23:51] are machine learning. It is not in our slavers. [01:23:54] So we will start deep learning directly [01:23:56] because not till today [01:24:04] till the last class whatever I have covered will be [01:24:07] the part of assignment one not today okay polynomial is a linear technically no no I'm [01:24:27] not agree Sudhansu if you are going to increase the degree of polynomially ultimate you are drawing [01:24:35] a curve not a line so I'm not agree with Sudhansu Saurabh yeah I appreciate your comment because [01:24:47] But really, as a teacher, it was a very difficult condition for me to know you are from the diverse background and many of you don't have any basic terminological understanding. [01:25:01] So I have taken extra pain to make you somehow bring in the common platform so that you may have a basic understanding about terminologies, things like that here and there. [01:25:13] So I have covered all those things. [01:25:15] it make my journey easy [01:25:17] in the later [01:25:19] days and otherwise you will not [01:25:21] understand anything if directly start from [01:25:23] the deep learning. So Sruti [01:25:34] I have uploaded the assignment so [01:25:36] IIT Patna team may [01:25:38] announce anytime [01:25:42] I don't know what are the [01:25:44] schedule but from my [01:25:47] side I have uploaded the assignment. [01:25:53] No Vijay I cannot do it. [01:25:55] All the things are with you. All the [01:25:57] notes i have uploaded in the moodle you can go through it okay all the topic i have covered i [01:26:03] cannot list over here yes because it's my duty to make the toughest topic in a simpler way so that [01:26:15] whenever you go to your books and and other videos you can catch it easily it's my duty [01:26:23] so okay thank you your your coding classes are running fine i hope so [01:26:39] Okay, thank you. Bye.