[00:00:37] Good evening, everybody. I hope my voice is clear to everybody. Okay, so thank you. We are starting our today class. So in the last class, we have seen many things, particularly I have covered what is training. Thank you. [00:01:04] What is training? Before that we have seen what is supervised learning? [00:01:16] What is unsupervised learning? What are the class? What are the labels? [00:01:24] What are the target variables? Many things we have seen in the last class. [00:01:32] I have covered what is training process. In the training process normally what we require [00:01:39] our data set is required and normally we split the data set into the two part. [00:01:46] Okay training data, training set we call and testing set. Okay and normally it is around 25 [00:02:00] around 75% of the given data we keep for training purpose and remaining around 25% data we keep for [00:02:10] the testing purpose. I think it was discussed in the last class. Am I correct? Yeah. Yeah, [00:02:24] I agree with you. It is around 25% to 30%. Yeah. So we have a small topic just briefly I want to [00:02:34] cover, there are various, understand this topic, there are various ways to [00:02:43] split the data, given data set. Out of those, today I am just introducing two [00:02:57] methods, fold out method, fold out method and k cross validation, k cross validation, okay, [00:03:17] value, yes, agree, okay, somebody is writing about the writing, okay, so notes are already [00:03:28] will be given to you, so there is no issue of the writing because whatever I am covering, [00:03:34] it is a complete separate notes will be given to you so don't give much focus on the way i'm [00:03:41] writing because everything is in the form of word text document like in the last class everything [00:03:47] it was covered like what is modeling what is training what is the setup of training and [00:03:53] testing data set okay how to split the data set fold out method and k cross or k fold cross [00:04:02] validation everything are here in clear notes it will be uploaded into the Moodle so you will get [00:04:11] everything okay yeah you will get everything whatever I am writing here whatever it will be [00:04:18] available even I will try to improve it so the topic is here there are various ways there are [00:04:25] not only the two ways there are various ways to split the given data set the most famous methods [00:04:32] are the holdout method and the k fold cross validation. So, starting is with first what [00:04:47] is what is what is holdout method. Recall the previous class discussion that was actually [00:05:01] the holdout method. In the holdout method what happened the data set we split into two parts. [00:05:07] we split data we split the data into two parts. So the major part that is around 70% [00:05:20] we call it it is a training data set, training set and remaining 30% we call it test data set. [00:05:32] okay so yesterday i have covered one method it was nothing but a simply a holdout method [00:05:40] okay today i'm going to cover very briefly about k-fold k-fold cross validation it is very important [00:05:53] because in the real life or in the real project we use k-fold cross validation it is a versatile [00:06:01] method okay so let me explain first if the data set is given to you like that please understand [00:06:13] otherwise you will have a lot of confusion and lot of confusion yeah complete data set is given [00:06:21] to you you need to decide the value of k what is k k means number of partition number of partition [00:06:30] number of partition of data set of data set this should be equal size it should be equal size [00:06:42] okay so suppose you want to partition the data into 5 equal power so the k will be 5 okay so [00:06:54] today we will not discuss how to decide the value of k just understand the procedure understand the [00:07:00] step of the method. K means number of part that you need to make of given data set. Agree? [00:07:10] So, K means number of partition of equal size. So, what we do? So, suppose K is equal to 5. [00:07:22] Assume that here K is equal to 5. So, I will partition the data K is equal to equal partition. [00:07:32] Okay, like that. So, this is k is equal to one first part, k is equal to two, k is equal to third [00:07:41] part, four part and five part of equal size. Okay, now understand how the training process [00:07:52] take place. Training process. It is very critical or very tricky. Understand. So, there will be [00:08:02] k number of iteration. There will be k number of iterations. There will be k number of iterations. [00:08:09] Okay. So, iteration 1. Understand. It is very tricky. Iteration 1. So, you will pick, [00:08:17] you will pick one part, one part as a testing set. Okay. And all remaining, understand all [00:08:33] remaining k minus 1, k minus 1 part combined, combined and use for training. What is the meaning [00:08:51] of that? Meaning of that is that, meaning of this, suppose this is the data set, you have make, [00:09:01] you have made five partition one two three four five iteration one any of the part you can [00:09:08] consider any of the part you pick randomly or sequentially it does not make any difference [00:09:14] keep that part for a testing purpose agree and remaining together combine it [00:09:23] it will become training purpose. Is it clear? So, iteration one, you train a model, whatever [00:09:33] the algorithm you have, you need to train with this mature data set and one part you have blocked [00:09:39] that you can use for the testing purpose. Is it clear? Now, iteration two, you have to repeat [00:09:54] this process. You have to repeat this process again. Again you have a five [00:10:04] partition. So suppose this partition earlier you have used as a [00:10:08] testing purpose. Now you have to use any other unused partition for a testing [00:10:15] purpose. So, suppose this time it is a testing set and remaining all, this and also this, [00:10:28] okay, you need to combine and it will become a training data set, training set, okay. [00:10:38] Same process we have to repeat for until all the partition has been used for a testing purpose. [00:10:52] Idea is clear? Setup is clear or not? Great. Okay. So, what is the benefit of k-fold cross [00:11:24] validation. What is the benefit of k fold cross validation? Just I want to see answer from your [00:11:37] side. I have discussed both the method. I have discussed versus holdout method. Holdout. How the [00:11:45] k fold cross validation is better than the holdout method? Okay. Any idea? Yes. Correct answer. Each [00:11:57] data set as touch all the data will be yeah yes yes yeah most of the answer are correct [00:12:14] yes i'm very happy to see the answer so yeah yes so it a number of iteration i mean is depend on [00:12:37] the k how you are deciding the k so it it is not right time to discuss how to decide the value of [00:12:44] k it's depend on the size of the data set number of feature of the data set so the same data set [00:12:49] you can develop the model by keeping the different value of the k. So you are correct. [00:12:57] You can use different value of k with the same dataset. Yes, okay. Yes, so k [00:13:17] bk is k is equal to number of iteration, number of partition, both are correct. [00:13:23] Because both are correct. Whatever the number of partition you have, [00:13:27] number of iteration automatically will be equal in that. So k is equal to number of [00:13:33] partition. If technically you want to ask, so answer is somebody will say k is equal to number [00:13:39] of partition of equal size number of partition and number of partition automatically will be [00:13:48] equal to the number of iteration. Automatically it will come. So now we are going to pick [00:14:07] a new topic as I promised. I will cover fundamental of machine learning. So let me again [00:14:16] make it like there is a two categories of the machine learning. Supervised learning. [00:14:24] Supervised learning. Yeah, they are the disjoint. There should not be any overlapping. [00:14:29] Sachin, there should not be any overlapping. You are correct. Is it clear? Sachin, there should be [00:14:42] yeah no overlapping yeah totally separated data set five equal parts five equal parts without any [00:14:50] overlapping classification and another is a regression agree so today i am covering here [00:15:11] the first fundamental algorithm linear regression and their variant linear [00:15:16] regression and their variant. I am going to cover it. Next class I will cover one of the basic [00:15:26] algorithm from the classification that is the logistic regression. Is it clear? So today we [00:15:33] are here. Supervised learning, unsupervised learning, I cannot repeat otherwise the whole [00:15:47] day will go and and we will not able to complete the course so just you just revisit the recording [00:15:56] before starting of the next class okay how k fold is feasible in the large volume of data set [00:16:08] okay okay so how if you are not going to use the k fold cross validation suppose it is a holdout [00:16:17] method. So, how the holdout method [00:16:19] is feasible? The same way [00:16:20] K-fold cross-validation is feasible. [00:16:25] Okay? It is more [00:16:27] feasible, Muthu, because [00:16:28] you are [00:16:29] ultimate. One part [00:16:33] you need to keep as a [00:16:35] testing purpose and [00:16:37] another combined part you need to as a [00:16:39] training purpose. Okay, [00:16:45] Muthu? So, Muthu is asking [00:16:47] a very logical question. [00:16:49] So, case 1. Understand [00:16:51] the case 1. [00:16:53] holdout method. Okay, holdout method. Okay, what you are doing? Suppose this is the data set. [00:17:02] Agree? Data set having one crore observations. According to Muthu, that is a very large data [00:17:08] set. So what you are doing? You are keeping 25% data as a testing data and remaining all as a [00:17:16] training data. Okay, training data. So this is 75 percent. Suppose it is 75 lakh. [00:17:29] Okay and this is 25 lakh. Okay, case one. So according to if it is feasible then why [00:17:38] case two is not feasible. One minute. So case two, case two is what same data set I have taken. [00:17:58] same data set I have taken I have divided to I have divided data into the multiple parts suppose [00:18:08] k is equal to 5 okay so suppose k is equal to 5 but k is equal to 4 suppose so here k is equal to [00:18:19] 4 means again 25 percent data for the testing purpose 70 percent data for the training purpose [00:18:26] us. Okay, so what is the problem here? Mutthu, what is the problem? Both are the same. Ultimate, [00:18:32] we are not increasing the size of data at all in any case. The same data I am using both the cases, [00:18:39] either it is a k fold cross variation or it is fold out method. Only number of iterations [00:18:47] are increasing. So it is better for us. We will have a better learning. We will have a better [00:18:56] learning. Is it clear? Okay, Muthu, it is clear, I think so. Got it. Okay, so we are starting now [00:19:16] in some pattern and then dividing K4. It's random. G1, it's a big question. [00:19:25] You cannot decide. You cannot decide it is a random or in sequence. Okay, that is a very [00:19:34] good question somebody has asked. So it depends. It depends. Okay. How? If the data set is sequential [00:19:46] data, you need to understand what is sequential data. I hope during your UG course you have [00:19:52] understood the sequential data and you have a data, another type, non-sequential data. [00:20:00] Non-sequential data. Can you give me example of sequential data or non-sequential data? [00:20:08] Sequential data means what? IoT data, NLP, text data, stock market data, weather data. [00:20:22] All are the sequential data. Non-sequential data means images and any other things. [00:20:30] So, if the data is a sequential data, the split should be sequentially, split must be, not should [00:20:40] be, must be sequentially. And if it is a non-sequential data, if you confirm in your [00:20:51] application, then you can split randomly. You can split random. Okay. Is it correct? G1. It was [00:21:03] great question. I have answered it. So, when we will start NLP, I will again cover that point. [00:21:09] I will again cover that point. What is sequential data? What is not sequential data? I will cover it. [00:21:15] Otherwise, you can just search and try to understand by yourself what are sequential data, [00:21:19] what are not sequencing. Okay, great. So it's the right time to start linear regression. [00:21:31] Linear regression algorithm. So I will upload this word file for you. [00:21:46] Okay, so today we are going to see what is the linear model means. A variant of linear regressor, [00:21:58] linear regressions are simple linear regression I will cover, multiple linear regression I will [00:22:03] cover, polynomial linear regression I will cover, training method very briefly. The gradient descent [00:22:11] or gradient descent is a part of the course I will cover during the deep learning models. When we [00:22:18] have a deep learning model, I will cover the gradient descent. So today I will not cover it. [00:22:22] I will give you just a brief idea about what is the least square method of training the linear [00:22:26] regression model. Hands-on will be on the implementing or coding classes. So linear [00:22:35] regression is one of the most common and most studied machine learning algorithm in this field. [00:22:45] We try to see how the linear regression algorithms look like, how we can represent all those things, [00:22:53] what are the assumptions, and how to prepare your data set for the linear regression model [00:22:59] and its training method. [00:23:01] It's very, very, very interesting. [00:23:03] I will cover everything. [00:23:04] You don't worry about that. [00:23:06] So starting with the simple definition of the linear regression. [00:23:10] So linear regression is a linear model. [00:23:13] Model that assumes. [00:23:15] So the question is that why it is linear model? [00:23:17] Why we call it linear? [00:23:19] It is called linear. [00:23:20] Why? Because it assumes a linear relationship between the input variable x and the single output variable y. [00:23:31] So, one by one I will cover it. [00:23:36] In the data set, now you are in better position to understand. Suppose this is the data set. [00:23:42] We have a lot of variable or feature like that and one target variable. [00:23:55] What we try to do, we try to see how the features that is given to you in your dataset are connected [00:24:06] to the target variable that we want so that by using this feature we can predict the target [00:24:13] variable. Okay, so here target variable is always a single variable or feature. We can have a many [00:24:24] feature. We have a many variable or many feature. If this is called, we call it input variable. I [00:24:33] have covered it already in the previous class. We call it output variable. Okay, output variable. [00:24:47] Is it clear? So it is written here a linear regression is a linear model because it assumes [00:24:57] the real linear relationship between input variables that may be many or maybe single [00:25:04] with a single output variable. So more specifically if you try to say why is output variable that you [00:25:12] you want to predict from the linear combination of the input variable linear combination of the [00:25:18] input variable okay so there are three variants linear regression linear regression is the method [00:25:32] there are the three variant first simple linear regression linear regression another was multiple [00:25:43] linear regression and third one is a polynomial linear regression. So, understand here this is [00:26:02] what simple linear regression? If number of input variable, number of input variable is equal to 1 [00:26:18] and number of output variable is equal to 1, we call it simple linear regression. [00:26:26] There is a one input variable and one output variable. [00:26:31] This combination we call it simple linear representation. [00:26:36] Multiple linearization means number of input variable will be greater than equal to 2. [00:26:48] Number of output variable always 1. [00:26:54] What is simple linear regression? What is multiple linear regression? I hope it is clear to everybody. [00:27:04] I will cover it later. What is polynomial linear regression? [00:27:11] So same thing is written here. When there is a single input variable and by default [00:27:21] we don't need to talk about there should be always a single output variable because there is always. [00:27:28] So if there is a single input variable, we call it simple linear regression. [00:27:31] If there are multiple input variables, we call it multiple linear regression. [00:27:38] Just terminological introduction. Now, in some book you will find one variant of linear regression [00:27:45] like least square linear regression. This variant is also in some of the literature. [00:27:56] So what it is, it is a training method, it is a training method, it is a training method. [00:28:08] So now understand one concept in machine learning, one ML algorithm is given, suppose it is [00:28:17] a linear regression and data set is given, data set is given. [00:28:25] there are multiple ways of training. There are multiple ways of training. Same algorithm, [00:28:32] either it is any kind of machine learning or deep learning algorithm, there are many ways [00:28:39] to perform the training. So there is no fixed one way through which you should train the model. [00:28:48] So here if this is the one way I call it least square method. [00:28:56] Least square method, I will cover it today, least square method. [00:29:00] If any of the linear regression follow the least square method for the training, [00:29:07] we call it least square linear regression. We call it least square linear regression. [00:29:16] this term is clear to everybody. There are many more. It is not right time to cover it [00:29:22] because it is a fundamental of typical machine learning course. [00:29:26] So, we have only introduction of the machine learning. That's why I'm covering what is [00:29:29] necessary only. Is it clear to everybody? So, there is no relationship between holdout method [00:29:54] and k cross validation. This square method is a training method. So, don't mix the concept. [00:30:01] holdout method and k fold cross relation are the way to split the dataset. [00:30:08] Okay and least square method is a training method. [00:30:12] Okay, is it clear? Don't get confused. [00:30:19] Yeah, so if you are joining the lead, please observe what I am teaching. [00:30:24] If in between, if you ask any question that I have already covered, [00:30:27] it will kill our time. Okay, so everybody else is clear? [00:30:35] fold out method or k fold cross validation are the splitting method okay and least square [00:30:53] is a training method both are different thing great now come to here i think everybody you [00:31:12] you recall your schooling you have seen this equation this equation is a line [00:31:18] equation. I think everybody agree? This is the line equation. Okay? Yeah. So it is nothing but [00:31:26] a simply a linear regression. It is nothing but a simply a linear regression equation. [00:31:32] Linear regression equation. Okay. So here we write in different way like here we like b0 plus b1 [00:31:42] x1 like this way. So this c we call it b0, this m we call it b1 or in many book also written like [00:31:52] theta0 plus theta1 x1 like that. You can also write the equation of the linear regression here [00:32:01] y is equal to w0 plus w1 x1. All are the same. In different different book people use a different [00:32:11] different notation so these are equal to exactly mx plus c okay here c means what either people [00:32:20] are using w0 theta 0 or b0 here m means people are replacing the with the symbol either b1 [00:32:30] theta 1 w1. Okay. So geometric point of view somebody is writing on the chat box. Suppose [00:32:44] this is the x-axis. This is the y-axis. Suppose this is the line. Okay. So this is called this [00:32:53] intercept. What it is? This is intercept means C or V0 or theta 0 or W0. Agree? Agree? And [00:33:07] an angle with axis with respect to x-axis, we call it what? We call it w1, theta1, m or p1 like [00:33:29] though. Okay, so one is this is angle. This is the angle with x-axis. I think everybody comfortable. [00:33:41] This is the intercept. [00:33:45] Intercept at y-axis. [00:33:47] Agree? [00:33:54] What is 3 variable? [00:33:56] Where is the 3 variables? [00:33:58] To spin, there is no 3 variable at all. [00:34:04] Okay. [00:34:05] Is it clear to everybody? [00:34:16] Yeah. [00:34:16] Somebody is confused with the 3 variable. [00:34:18] I don't know why. [00:34:19] I have explained everything. [00:34:21] These are the symbols. [00:34:22] Whatever the symbol you want, you can use. [00:34:25] Okay. [00:34:27] So, I want to extend. [00:34:32] it is a two-dimensional, whatever the way I have discussed it, two-dimensional, two-dimensional view. [00:34:43] We have only x-axis and we have only y-axis. If you have more dimension, then what happen? [00:34:53] If you have more dimension, then, okay, what is this? What happen if you have more dimension? [00:35:07] So the equation will be like that y is equal to if I use this way theta 0 theta 1 x 1 plus [00:35:17] theta 2 x 2 like that like that you can add many dimension. Is it clear? Is it clear or not [00:35:29] this equation? I am expanding the equation of the line in many dimensions. That's simple thing. [00:35:38] okay how to now the next question how to estimate the value of this coefficient this is called [00:35:52] coefficient okay so you can call it coefficient or you can call it weight I think every you are [00:36:03] more familiar with the term weight so you can write this equation w0 plus I will not repeat [00:36:11] that part again like w2 x2 like w and xn so the question is that how to calculate tell me how to [00:36:23] calculate it's very interesting everybody should be very much careful and and and and sincere and [00:36:31] focus for today lecture how to calculate these value these value any idea yeah yes yeah thank [00:36:52] you one more term people have used this is this is also called bias yes so intercept and bias both [00:37:05] are same just just a terminological introduction intercept you can call in geometry in machine [00:37:13] learning we call it the term bias both are same okay i have i have just mentioned in the notes [00:37:22] okay look intercept and bias and coefficient now come back to our discussion how to calculate [00:37:33] these value any any idea how to estimate these value hit and try hit and trial put other dimension [00:37:57] zero more answer i am looking yes use line equation already the line equation is given [00:38:03] okay, your answer should be, your answer should be, it's not our heading, it's not [00:38:17] our task, we should not, we should not estimate these values, it's not our task, okay, answer [00:38:33] is that why the dataset is required then? Dataset will be there, training will be there, [00:38:40] the training process. After the training, after the training, training process will give you [00:38:47] all these values, all these values. This is not our task. It's a responsibility of the algorithm. [00:38:53] It's a responsibility of the training method. So Rajiv and other who are trying to answer this [00:39:01] question. All are wrong. If you are able to solve by yourself then why data set is required? Raju [00:39:10] think and try to answer. Rajiv and Herz everybody have written. You are solving it mathematically [00:39:18] without machine learning process. You might have studied in the schooling but it is not typical [00:39:25] math y is equal to mx plus c. We are using linear regression in machine learning. So the data set [00:39:31] will be there yeah good question again so here y means output variable yes good question output [00:39:42] variable or target variable and other x i so i can be from 1 to n these are the input variable [00:39:55] these are the input variable or feature. Agree? Yeah. So, let me explain with one more example. [00:40:07] Suppose you want to predict salary of particular CTC or package that may be offered during the [00:40:18] placement drive and suppose this is the data set is given to you. First column is suppose [00:40:24] first SAM [00:40:26] CGPA [00:40:30] okay [00:40:31] this is second SAM [00:40:33] CGPA like that [00:40:35] this is your [00:40:38] branch math whether you are [00:40:40] from CSE, IT [00:40:42] XYZ this is your [00:40:44] internship detail [00:40:46] internship detail [00:40:48] okay this is [00:40:50] your programming skill like that [00:40:52] and this is your [00:40:54] CTC. So, this data set is given already. Your objective is to train. I am writing a task. [00:41:02] Your objective is to get a model that will predict what? That will predict CTC of a student. [00:41:19] Agree? [00:41:21] This problem is clear. [00:41:22] Objective is clear. [00:41:24] So you have to write an equation. [00:41:36] So y is equal to what? [00:41:38] Ctc. [00:41:39] This is b0 plus b1. [00:41:43] What is x1? [00:41:45] First same cgpa plus b2 from the data set. [00:41:53] Second same cgpa plus b3. [00:42:00] B3 is a branch. Okay. Then plus B4. B4 is what? Internship. Internship plus B5 programming skill. [00:42:22] Yeah. This is the equation. This is the equation. Okay. How to map the given data set into the [00:42:35] equation. I hope it is clear to everybody. So this is the right way to visualize the data set [00:42:44] is given to you and how to write the equation. Okay, B0 will not map anybody. [00:42:54] Okay, this is the bias, this is the intercept. Okay, you forget this, what is B1, X1? [00:43:05] okay like so x1 is a one variable okay so we only associate coefficient with [00:43:16] features we have extra coefficient we call it bias or intercept this is the where the line [00:43:24] cut on the y-axis so there is no variable we need to associate with this one it is a bias or [00:43:30] intercept. No, no, no, at least no, you cannot say. Okay. Yeah. Yeah. Why is CTC? Whatever the target [00:43:46] variable you want, it will be Y. Okay. So I will explain all these working with example. So what [00:44:02] I'm going to do, I'm just taking example, example. Through that example, I will explain the training [00:44:12] process. I will explain the training process based on the least square method, based on the least [00:44:23] square method. Why the y is intercept is called the bias? There is no reason, [00:44:35] just this is a termological introduction. So you can call anything else, it doesn't matter. [00:44:42] So, there is no any scientific answer why we call it bias. [00:44:58] So I will upload this file in the Moodle. [00:45:02] So initially, it has given some sample of application that comes under the linear regression [00:45:13] like from large list of donors predicting how much each one will donate. So it is a kind of [00:45:21] linear regression problem because output variable is what? How much money he or c is going to donate. [00:45:28] So if your output variable is a continuous variable, the problem will become a linear regression. [00:45:35] So you can refer it, there are some examples of applications that comes under the linear regression. [00:45:43] Yeah, so look here I have taken one small data set. I will explain how the linear regression [00:45:49] work on it. There are two variables are given in the data set. First one is the size of the [00:45:55] house in square feet and second one is the price. So what we want to predict, I want to train a [00:46:02] model in this data set so that your model will predict the price of the house based on the input [00:46:09] variable size of the house. Is it clear? Very simplest data set I have taken having only single [00:46:17] feature. That's why the linear regression in this case will become the simple linear regression. [00:46:23] You try to recall what is the definition of the simple linear regression? There should be one [00:46:30] output variable and one input variable. So target is price. I want to predict the price based on what? [00:46:38] based on the input variable size of the house. Yes, great, great. One input variable, one output [00:46:45] variable. Yes, yes. Okay, so what will be the equation here? The equation will be the [00:46:54] price of the house. Agree? Price of the house is equal to b0 plus b1 and size of the house. [00:47:05] okay is it clear to everybody with this given data set this will be the [00:47:15] equation of the linear regression great now yes yeah so yeah so you if you try to visualize [00:47:32] if you try to one second yeah if you try to visualize how many observations are there in [00:47:48] in this data set. Look, 1, 2, 3, 4, 5, 6, 7, 8. So if price of the house is y-axis and [00:48:00] size of house is x-axis, you can visualize all data points. Look, x-axis here is the [00:48:08] area or size of the house, y-axis is the price of the house and these white color points [00:48:17] are nothing but simply a data, simply observations. Is it clear to everybody how to visualize [00:48:25] the two-dimensional data into the plot? So this is x-axis, this is y-axis, x-axis is [00:48:32] the size, y-axis is the price and these are the data. Is it clear to everybody this diagram? [00:48:45] question on this diagram please ask. Now this is the equation I have already [00:48:56] written. Price will become the output variable then theta 0 plus theta 1 and [00:49:02] the area and your objective is what? To calculate the value of theta 0 and [00:49:08] theta 1 because they are these only the coefficient that is unknown. Price is [00:49:13] known to me, it comes from the data set, area comes from the data set, which [00:49:21] coefficients value that is unknown, these are the coefficients, theta 0 and theta 1. [00:49:30] So our objective is what? Our objective is through the training with [00:49:47] With data set, we will estimate these, agree or if you don't want to mention here B0 or [00:50:04] B1. [00:50:07] Is it clear? [00:50:12] Is it clear up to this moment? [00:50:14] So if I ask what is the output of training, can you answer it? [00:50:22] is the output of training. Output of the training is value of coefficient on me or if I say [00:50:36] right value or okay understand right value of the coefficient. So that is the purpose [00:50:46] of the training. Got it? Yes. Yes. Now come back to the notes here. Yeah. So this is a one picture [00:51:04] where all the observations are displayed on the 2D space. Great. Yeah. This is very important. [00:51:15] So, come here, yes, it's most tricky and important part, please. [00:51:29] Suppose these are the datasets, okay, these are the data, agree, everybody agree, suppose [00:51:38] these are data, I want to draw a line, I want to draw a line, what is this, this is your [00:51:46] linear regression model, I want to draw a line. [00:51:51] So that by giving the value of x, my line will predict the value of y. [00:51:59] How to do it? Just focus on my discussion. If I request, do not ask the question in between. [00:52:13] Just see what I am doing. So if you are able to see here it in light color, one line is [00:52:22] drawn over here i want to draw a line okay how to draw a line that is the second question [00:52:35] okay so the question is here how to draw a line first tell me training is starting i am [00:52:46] i'm going to explain the training i'm i'm explaining the training process i'm explaining the [00:52:51] training process training process of linear regression using a least square method using the [00:53:03] least square method i'm explaining that part okay so the first part first step of the training is [00:53:14] what? Draw a random line. Draw a random line. Okay, draw a random line. Line, when I say the [00:53:26] random line means it is a linear regression model. It is a linear regression model. Okay, [00:53:32] so draw a random line. So now question is that how to draw a random line? [00:53:39] Anyone can answer it. How to draw a random line? [00:53:45] From scratch I'm explaining you will not find any video or any other way where people are explaining [00:53:52] in that level. So the first step is that in the linear regression draw a random line. How to draw [00:53:58] a random line? I'm just waiting for your answer and suppose in this case equation is the price [00:54:11] is equal to b0 plus b1 size no nobody is answering no i didn't get any correct answer [00:54:26] if i ask this question in interview you will get zero marks zero marks again no no yes [00:54:38] tusar has written correct answer everybody please see the answer given by the tusar [00:54:48] yeah, you assume value of v0, v1, any random value, any random value. [00:54:58] Or you can initialize with them with the 0, 0. So this is, for example, these are the weight w1, [00:55:07] wmin. In machine learning, we call the concept of the weight initialization. We call it the [00:55:15] the weight initialization. Weight initialization means whatever the coefficient you are using, [00:55:25] you initialize with the 0 or 0.1 with the small value or any other random value. Whatever [00:55:31] way you want you can. Is it clear? For example, in this case, price was the here, I have taken [00:55:41] 25 W0, 25 plus and 15, this is the price. Okay, so I have taken random value of B0, [00:55:58] that is 25 random value of b1 that is 15 is it clear to everybody up to this moment every [00:56:11] everything is clear first step of the training draw a random line i have explained how to draw [00:56:18] a random line got it so first step is over and suppose it's depend on what value you are taking [00:56:29] suppose these were the data points you cannot change the data point because they comes from [00:56:35] the data set for example first random line you have drawn this this is the first line [00:56:41] up to this moment i have explained everything is the first line i have drawn there is a random line [00:56:47] okay is it clear now now i will i will predict i will predict the price of the house price of the [00:57:11] house using this first line. First line or linear regression model. This is the first model you have [00:57:24] drawn. This linear regression line is nothing but a simply a model you have drawn. Now I will [00:57:31] predict the value of price. How you can predict the value of price by using this line? Any idea? [00:57:36] Okay, suppose this is the size of the house 100 for example, this is the size of the house 100 [00:57:48] and price is 25 lakh, suppose. Okay, I need to draw a vertical line on the model [00:58:03] and corresponding value of y-axis. [00:58:07] Suppose value of y-axis is 10 lakh. [00:58:11] Okay. [00:58:12] So the target value is what? [00:58:14] 25 lakh. [00:58:16] That is the original value that is coming from the data set. [00:58:18] And what my line is predicting, my model is predicting 10 lakh. [00:58:22] Okay. [00:58:24] Is it clear? [00:58:26] Every data point you need to map on the line [00:58:29] and corresponding value of the y-axis is the value of predicted by [00:58:33] your line. Okay, is it clear? I have explained how to use this line or model for a prediction purpose. [00:58:47] Any doubt? Yeah, it is also here in this diagram. Wait, yeah. Okay, suppose random value of theta [00:59:01] 0 is 4. In this example, theta 1 is 0.02. This is the line. X axis presents the size of the house. [00:59:09] Y axis presents price of the house. These are the data point and that is a real data values [00:59:19] and first model I have trained and the model is predicting the price of the house that is [00:59:28] corresponding to the y-axis. Agree? So, yes, there is a difference between what is target value and [00:59:36] what your line is predicting. Okay. This is clear? Everybody? Okay. So, yeah. So, this is the table, [00:59:55] very important table. Please understand. Please understand this important table. So, this is the [01:00:03] house size okay this is the target variable and this is the predicted [01:00:13] price from your model so target variable your true price was 35 of the house of [01:00:28] 1000 square feet house of 1000 square feet real price is 35 lakh real price is 35 lakh [01:00:37] but when you map on the line it will predict around 24 lakh okay the table is clear [01:00:47] so this column present the target variable ground truth and next column present what [01:00:55] your model is predicting against every input and the last column is the error because [01:01:03] error means what the deviation and in mathematical you will say the difference between target [01:01:12] variable and predicted target value and the predicted value the difference between these [01:01:20] two value we call the error. Okay. Is it clear to everybody up to this moment? Great. Great. [01:01:35] So, how to calculate the total error? Tell me. Total error. According to you, error 1 plus error [01:01:46] 2 dot dot dot dot error n. n means total number of observations from the training data set. [01:01:53] okay for this example one two three four four observations were there [01:02:00] every observations will contribute some error it may be zero may be positive may be negative [01:02:06] agree so you need to calculate the total error given by your this line you need to sum it [01:02:13] okay yes so yeah some of the errors are positive i think everybody understands some of the errors [01:02:27] are negative so it may happen if you add these errors together the total error may be zero [01:02:34] or close to the zero close to the zero so this is not a right way correct way is that what is [01:02:42] solution of this problem there are two solutions either you can use the absolute value okay like [01:02:53] that. It will give you total error. Agree? So, we call it total absolute error. We call [01:03:02] it this formula total absolute error of your model. Okay? This formula is clear. What is [01:03:17] the total absolute error? It is clear to everybody. Another formula. Another formula is square [01:03:26] it. Square of each error like that and then adding. This is called SSE. [01:03:40] SSE means sum of squared error. Very famous term sum of squared error. Agree? [01:03:52] I am just an introduction of new term. Total absolute error, sum of square error, [01:03:57] both things should be clear to everybody. [01:04:04] Great. [01:04:07] So, it's not [01:04:09] a right way. Again, this is not [01:04:11] a right way. Why? [01:04:16] Because here [01:04:17] total error in both the way [01:04:20] total [01:04:21] error also depends [01:04:24] on [01:04:25] depends on size [01:04:28] of the data. [01:04:29] Size of the data. [01:04:32] If the data set have more number of [01:04:34] observations, you will feel [01:04:36] it will offer more larger error. So what is the solution of this problem? [01:04:42] Mean absolute error, very famous term. Mean absolute error. What is this? Same formula [01:04:55] just we have seen divided by n. People use this formula because it is independent of the size of [01:05:10] of the data set. Similarly, average or mean sum of square error is a better formula. Okay? Yes. [01:05:43] So now you have two options. Now you have two options. Option A, mean absolute error you can use [01:05:52] or you can use average sst agree there are many more options this is not a right time to [01:06:03] introduce here there are many more options okay whatever the option you will choose it will give [01:06:10] you different model it will give you a different model the performance of model will be different [01:06:17] That's why I discuss today at the starting of the lecture. [01:06:24] The moment you will change the underlying idea of training, [01:06:30] you will have a different model. [01:06:31] There are many options. [01:06:33] Either you can use mean absolute error, you will get a model. [01:06:37] You can use average SSE, you will get a model. [01:06:42] And there are many, many, many, many more options. [01:06:44] So, in the real time, in the real application, what happens if you are from the industry, [01:06:49] real application? [01:06:50] Hit and try. [01:06:51] There is no correct answer. [01:06:52] Hit and try. [01:06:53] Which method will give you the best result? [01:06:56] You should choose it. [01:06:58] Okay? [01:06:59] Just my objective is to make it clear there is no any fixed path of the training. [01:07:04] During the training, there are many options. [01:07:07] Whatever the option you are choosing, it will impact the quality of the model. [01:07:11] Okay? [01:07:15] is it clear to everybody great now come to the least square method you may be wondering [01:07:26] what is the least square matter of training least square method use this formula average [01:07:35] ss agree if you are choosing to calculate the total error average sum of square error [01:07:43] this concept we call the least square [01:07:45] method [01:07:45] ok [01:07:47] again why we are squaring [01:07:53] the error you answer [01:07:54] you answer it first why we need to square [01:07:57] the error I already covered it [01:07:59] answer is not here answer is [01:08:08] why we have done absolute error [01:08:10] because there are some positive errors [01:08:14] if you don't focus [01:08:16] during the discussion such questions [01:08:18] will come unnecessarily [01:08:19] I have answered it [01:08:21] Some errors are positive, some errors are negative. [01:08:26] They can cancel each other. [01:08:29] So ultimately you will be misguided, you will see your model error is total zero or close [01:08:35] to zero. [01:08:36] You will be happy to see that your model is very good. [01:08:38] But it is not coming because of the performance, because of the errors are positive and negatives. [01:08:45] So to solve this problem, we have two methods and many more methods. [01:08:49] So one of the method is squaring each turn so that negative turn will become positive. [01:08:55] Okay. [01:08:56] So everybody got it? [01:08:57] What is the least square method? [01:09:04] Okay. [01:09:04] Now, now the question is how to reduce. [01:09:11] How to reduce the error? [01:09:16] This is the next question of the training. [01:09:18] I am covering the training. [01:09:19] It is not completed. [01:09:21] How to reduce the error? [01:09:22] You tell me. [01:09:29] Yes. [01:09:30] Correct answer, Jitain. [01:09:35] Yes. [01:09:36] so answer is here [01:09:39] hypothetically I am answering [01:09:43] okay you understand [01:09:44] so this was the initial [01:09:47] setup assume that [01:09:49] yeah [01:09:51] suppose is the first line I have [01:09:53] drawn okay [01:09:54] so I am mentioning here the first line [01:09:56] now I have to draw many more lines [01:10:01] agree like many [01:10:02] more lines many more lines [01:10:04] many more lines many more [01:10:06] lines here okay [01:10:08] So this is suppose line number 2, line number 3. [01:10:12] A model you can say the model 4, model 5, model 6. [01:10:17] Similarly, we have a M number of model can be there. [01:10:21] This idea is clear. [01:10:25] And every model we have to calculate the total error. [01:10:28] Total, I'm mentioning here total error 1, total error 3, sorry this was the 2, total error 4. [01:10:44] this total error 5, total error 6. Is it clear? So, suppose, suppose you have drawn [01:10:58] or you have a model, you have drawn M lines, M models. Okay. Okay. So, for a simplicity, [01:11:09] I am saying M1, M2, no, no, like, like, L1, L2, L3. [01:11:17] These are the lines, dot, dot, dot, dot, dot, dot, M number of lines. [01:11:23] Each line will give you some total error. [01:11:26] So this is, I am explaining total error 1, total error 2, total error 3. [01:11:34] Similarly, total error M. Is it clear? [01:11:37] so which line you will select question is that which line you will select as a [01:11:47] final line as the as a final line or final model yes least error correct [01:12:05] answer. The line which offers the least error. Correct answer, correct answer. Line [01:12:22] is minimum error. Sometimes we will call it minimum error. So because of this word least, [01:12:30] this method we call it what? Now you can connect everything least [01:12:35] square because we square the error. So, least square method because of this concept. This [01:12:43] training method is given the least square method. Okay. So, suppose, suppose, please focus over here. [01:13:11] Suppose there are many lines you have drawn. Okay. And suppose this is the best one. Agree? [01:13:23] Best one means what? That is we call it the line which offer the least error. Okay. So, [01:13:35] suppose this is the best line. This is the best line. Okay. Now, you need to see suppose this is [01:13:56] the cut at the y-axis. Suppose it is 10 and angle with the x-axis is 5. So what will the final [01:14:08] model here? Final model will be price is equal to 10 plus 5 size. That is the your final model. [01:14:19] Training is over. That is the final one. I hope everything is crystal clear now. [01:14:30] up to this moment. So what was the objective? Objective was to estimate the value of b0 [01:14:39] and b1. So this is the way we have estimated the value of b0 and b1. You don't need to worry about [01:14:47] initially what I answer you don't need to calculate the value manually. [01:14:52] It comes through the data set. It comes through the training process. [01:14:56] you don't require anything else to calculate manually now that what is clear to everybody [01:15:02] great okay the most important part who update the weight who update the coefficient you tell me [01:15:29] because the first time the first time what you have done suppose this was the price and random [01:15:41] value you have taken 25. Suppose this is 30 and this is the size. This is the first line. Agree? [01:15:47] First time random line you have drawn. Is it clear to everybody? Random line you have drawn. [01:15:54] Okay. But when you have to draw the second line, you have to draw the second line. Yes, second. [01:16:03] How you are going to change these value? Either you want to increase or you want to decrease. [01:16:09] tell me. That is a million dollar question. So, how this value you will estimate? How are you [01:16:20] going to update? You are going to increase or decrease this value? Okay, based on the error, [01:16:33] how do you decide should I increase or decrease? Okay, suppose average error is 80, tell me. [01:16:41] what you will do? You will increase this value or decrease? Tell me. Suppose [01:16:47] average error is 80. Now tell me. Okay average error is high. No, no, no, no, not at all. [01:16:57] Totally wrong answer. How you are deciding with the error? Suppose it is not [01:17:09] 80. It is 800. Then okay. So you all are wrong. Answer is here. That is the last [01:17:30] discussion. Last discussion. We need optimizer. We need the optimizer. This is [01:17:36] not manual process. Every time you just come into the loop. No, optimizer. [01:17:47] You need to use the optimizer. Who will update the weight? You don't need to [01:17:53] involve manually? Who will update? Who will update the coefficient? There is no [01:18:02] any human involvement. Agree? So who is the optimizer? There are many options. [01:18:08] Again, there are many options. There are many options. The most famous, the most [01:18:17] famous is what? Gradient descent. I will not cover it. It is a part of deep learning. [01:18:26] The gradient descent. It's a responsibility of the gradient descent to update, [01:18:34] to update all the coefficients. It is maybe b0, maybe b1, there may be n number of coefficients. [01:18:41] update the weight such that [01:18:43] such that [01:18:47] in every iteration [01:18:50] in every [01:18:51] iteration [01:18:52] it reduce [01:18:57] total error. [01:19:00] Got it? [01:19:01] We are not going to learn [01:19:03] what is a gradient descent. [01:19:04] You need to understand the objective of the gradient descent. [01:19:08] It is okay. [01:19:09] So whatever you were thinking, this is your work, [01:19:11] your work will be done by the gradient descent. [01:19:15] Okay, there are many variants of the gradient descent. [01:19:17] Like somebody here written a stochastic gradient descent. [01:19:23] It is a very good batch gradient descent. [01:19:27] Adam, there are many, many, many, many, many variants out there. [01:19:32] Is it clear to everybody? [01:19:34] I have completed the linear regression. [01:19:40] I have completed the linear regression. Come back to the diagram. Yes, everything is written. Look, [01:19:50] each square, each term you need to square it, then sum it. Objective is to minimize it. [01:19:57] Okay, this is the formula of calculating the error. This is real value, target value minus, [01:20:05] this is a predicted value. Square it, you will get the error. Okay, we call it sum of square error. [01:20:12] Okay, yeah. Now, come on back to the screen. Somebody has already asked this question. It [01:20:21] is possible to have multiple variables. Why not? This is another example. Suppose we have a data [01:20:28] set having a two input variable, the size of the house plus number of bedroom in the house. [01:20:36] So, now we have a two input variable and output variable is always single. [01:20:41] So, now here we don't need to draw a line. [01:20:44] Here it is now the three dimensional view. [01:20:48] We try to draw a plane or hyperplane. [01:20:52] Okay. [01:20:53] So, the equation will become different. [01:20:55] Like here price is equal to theta 0 plus theta 1. [01:21:00] First input variable area. [01:21:02] Then next input variable number of bedroom. [01:21:05] Else everything is same. [01:21:07] you need to use this plane to predict the value. Real value is this one. Target value is this one. [01:21:17] Predicted value is this one. These are the errors. Again, you need to square it, average it, [01:21:21] apply the gradient descent. It will update the weight until you will get the least error. [01:21:27] So, now number of feature does not make any difference to understand the concept of the [01:21:32] linear regression. Agree? Very simple. Very simple. Okay. This is the multiple linear regression [01:21:40] because we have more than one input variable. Okay. Great. Now, the last part we are discussing [01:21:51] here. Adjunctions are not going to cover here. Leave it. Yeah. Now, the last topic for today [01:22:08] discussion polynomial polynomial linear regress agree last important part thank you Rahul if it [01:22:23] was a machine learning I take two to three two to three session two to three session to complete [01:22:31] the linear regress if today I have to cover all that stuff into one session only because our [01:22:39] subject is not machine learning. Our subject is more about deep learning. So I'm running in very [01:22:45] fast manner. Otherwise you will enjoy much more. Okay, leave it. Suppose I want to predict a muscle [01:22:55] power. Can you? Muscle power. Muscle power based on the age of a human. Agree? I want to predict [01:23:08] the muscle power. This is the value that I want to predict. An input variable will be what? Age. [01:23:16] Input variable. Okay. So, what is the relationship between muscle power? Can you draw? [01:23:23] Muscle strength, yeah, muscles power versus age of a human being. What is the relationship between [01:23:31] these 2 variables. I think everybody agree it will be like that. Age and muscles power. It will be [01:23:42] like that for a small suppose it is 1 year then 2 year then 3 year then 20 year then 30 year then [01:23:51] 100 year like that. So it will be like that. I think everybody agree? Agree? So now tell me [01:24:01] the relationship between [01:24:05] muscles, power and age [01:24:11] is not linear. [01:24:15] Agree? [01:24:19] Everybody agree or not? [01:24:20] So in this case, [01:24:24] simple linear regression [01:24:25] or multiple linear regression [01:24:32] will not work. [01:24:36] I think you also should be agree with this will not work because the relationship between input [01:24:42] variable and output variable is not linear. So what you have to do in this case, we need to draw [01:24:48] a curve. We need to draw a curve, not a line. So whenever you draw a curve, not a line, [01:25:02] we call it polynomial linear regression, polynomial linear regression. After this moment [01:25:11] things are clear, great. So suppose the data set is given to you, age versus muscles power, [01:25:26] data is like that, okay. Data is like that, okay. So suppose you are trying to draw a linear regression [01:25:36] line, I think it will be the best line. This line will give you the least error. Assume that you [01:25:48] have drawn, you have trained the linear regression line on this data set. So suppose this is the [01:25:52] final line. Assume that. But this line is not following the way the data is distributed. [01:26:00] Agree? So you don't want that line because this line will not give you the satisfactory result. [01:26:06] you want a curve that will follow this data distribution. So, it will be the [01:26:14] better model. So, how to achieve this? [01:26:21] How to achieve this? Through polynomial linear regression. That is the idea. [01:26:31] Okay, so in this case, what is the characteristics of the polynomial linear regression? [01:26:42] Suppose this is a y, this is b0, b1, here whatever the term or feature you are using, [01:26:50] the degree of polynomiality you can change like that, like that. Okay, so because of [01:27:03] the degree of these features are not linear or not single, it can be anything because of that [01:27:10] we call this polynomial. The degree of polynomials will be different. Yes, Mohit, you are correct. [01:27:26] You can call it polynomial regression. It's better format. I agree with Mohit. Okay, [01:27:35] by visualizing it. So, Joginder, by visualizing it, you need to visualize the relationship between [01:27:40] input variable and output variable. Okay, Joginder, now you may have a question. Sir, how do you know [01:27:49] these features the degree of degree of probability should be 2 or 3 or 4 or under root or square root [01:27:58] it's again hit and try final answer there is no correct formula hit and try okay so this is the [01:28:10] example I have given suppose this is the age is the salary I want to predict the salary of a [01:28:16] particular person based on the age. If you try to visualize, you will sense it. The relationship [01:28:22] is not linear. This is the right curve that will fit on the data. But if you try to draw a line, [01:28:30] you can do it like linear regression salary is equal to theta 0 plus theta 1 age. But that will [01:28:38] not give you satisfactory results. [01:28:43] Error will always be higher size. So, solutions are [01:28:46] there. You can increase the degree of polynomiality. Like [01:28:50] theta 0, theta 1 plus h plus theta 2 h square. And you can [01:28:54] add in many ways. What will be the correct equation? [01:28:59] Nobody knows. Hit and try, hit and try, hit and try, hit and try. [01:29:06] Okay? Yes. [01:29:09] Yes, like that. [01:29:12] If there are many more variables, you can add and you can play with the degree of polynomiality. [01:29:26] So yes, Muthu, people are using both the word, either polynomial regression or polynomial linear regression. [01:29:32] So it doesn't make any much difference the way you like you can use the term. [01:29:42] Yes, there can be multiple points. [01:29:44] In this case, it will be a polynomial curve. [01:29:47] Okay. [01:29:48] Anirudh, in that case you will have a 3D curve. So now because it's just a recap, my objective [01:30:02] was just the recap of the linear regression I have covered it. Now this is your [01:30:11] Your duty, understand that your duty to study in detail, you study in detail. [01:30:20] In detail. [01:30:21] Agree? [01:30:22] Whatever the my responsibility, I have taken the extra pain, extra time to cover the linear [01:30:27] regression. [01:30:28] There are many more things in the linear regression, many more things. [01:30:32] So please refer other books, video and other sources. [01:30:37] Okay. [01:30:38] a small announcement next class next class okay on i think it is uh next tuesday i'm talking about [01:30:48] tuesday agree it is uh uh 8th september itself so there will be no class i am on the leave there [01:30:58] will be no class okay you will get a notification don't worry about that this is a simple announcement [01:31:05] The next class of the same next class in this week, in this week, it is on Saturday, I think, [01:31:15] Saturday, it will be there as it is. I'm talking about the class on 8th September only. [01:31:21] Other class will be as it is. Only 8th September. Okay, in this week, Saturday, there is a class, [01:31:29] it will be there. Okay, so thank you. Time is over. You may be waiting for the next class. [01:31:44] uh okay so we are going to leave it here and and if you have any questions you can ask in the next