1 00:00:00,733 --> 00:00:01,900 Welcome back to the Ultimate. 2 00:00:01,900 --> 00:00:03,900 Data Science course and I am super. 3 00:00:03,900 --> 00:00:04,933 Excited about today. 4 00:00:04,933 --> 00:00:08,100 I've got an incredible tutorial prepared for you. 5 00:00:08,100 --> 00:00:11,400 We're going to cover off a very important topic and that is how to build. 6 00:00:11,566 --> 00:00:13,633 Models. Step by step. 7 00:00:13,633 --> 00:00:15,100 I couldn't hold myself. 8 00:00:15,100 --> 00:00:19,333 I had to add that extra line, step by step to the name of the tutorial 9 00:00:19,400 --> 00:00:22,500 because that is exactly what we're going to be looking at. 10 00:00:22,866 --> 00:00:24,466 I'm going to give you a framework 11 00:00:24,466 --> 00:00:28,100 for several different methods, and it's all going to be step by step. 12 00:00:28,266 --> 00:00:31,066 So let's jump straight into it. 13 00:00:31,066 --> 00:00:33,266 Do you remember the good old days when we had. 14 00:00:33,266 --> 00:00:36,266 One dependent variable and one independent variable? 15 00:00:36,300 --> 00:00:37,500 Everything was easy 16 00:00:37,500 --> 00:00:41,566 and we just had a simple linear regression that we had to build. 17 00:00:41,566 --> 00:00:43,633 And everything worked great. 18 00:00:43,633 --> 00:00:46,933 But now in our data we have all. These. 19 00:00:46,933 --> 00:00:48,066 Columns. 20 00:00:48,066 --> 00:00:49,700 Those easy days are gone. 21 00:00:49,700 --> 00:00:51,466 Now all of these columns are. 22 00:00:51,466 --> 00:00:53,133 Potential predictors for. 23 00:00:53,133 --> 00:00:55,066 Our dependent variable. 24 00:00:55,066 --> 00:00:57,233 And there's just so many of them. 25 00:00:57,233 --> 00:00:58,133 And we. 26 00:00:58,133 --> 00:01:01,166 Need to decide which ones we want to keep and which. 27 00:01:01,166 --> 00:01:03,366 Ones we want to throw out. 28 00:01:03,366 --> 00:01:06,766 And you'll ask why do we need to throw out columns? 29 00:01:06,766 --> 00:01:08,066 Why do we need to get rid of data? 30 00:01:08,066 --> 00:01:10,100 Why can't we just use everything. 31 00:01:10,100 --> 00:01:11,133 In our model? 32 00:01:11,133 --> 00:01:12,966 Well, I can think of two reasons off. 33 00:01:12,966 --> 00:01:14,000 The top of my head. 34 00:01:14,000 --> 00:01:17,000 Number one is garbage in, garbage out. 35 00:01:17,200 --> 00:01:18,900 If you throw. In a lot. Of stuff into. 36 00:01:18,900 --> 00:01:23,200 Your model, then your model will not be a good model. 37 00:01:23,200 --> 00:01:26,900 It won't be reliable, it won't be doing what it's supposed to be doing. 38 00:01:26,900 --> 00:01:30,333 It's going to be a, so to speak, garbage model. 39 00:01:30,600 --> 00:01:35,033 And number two, at the end of the day, you're going to have to explain these. 40 00:01:35,033 --> 00:01:36,766 Variables and understand 41 00:01:36,766 --> 00:01:40,500 the not just the math behind them, but actually what it means that. 42 00:01:41,100 --> 00:01:44,166 Certain variables predict the behavior of your. 43 00:01:44,166 --> 00:01:45,566 Dependent variable. 44 00:01:45,566 --> 00:01:46,100 And you will. 45 00:01:46,100 --> 00:01:49,566 Have to explain that to your executives, to your boss, to, 46 00:01:50,100 --> 00:01:51,300 people you're presenting to. 47 00:01:51,300 --> 00:01:52,166 So if you have a. 48 00:01:52,166 --> 00:01:55,800 Thousand variables, it's not going to be practical to try and explain. 49 00:01:55,800 --> 00:01:56,000 That. 50 00:01:56,000 --> 00:01:58,833 So you want to keep only the very important. 51 00:01:58,833 --> 00:02:01,833 Ones, the ones that actually predict something. 52 00:02:01,866 --> 00:02:04,433 So how do we. Construct a model? 53 00:02:04,433 --> 00:02:08,400 This is the process of building the model, selecting the right variables. 54 00:02:09,133 --> 00:02:10,633 So how do we construct a model. 55 00:02:10,633 --> 00:02:12,600 Well there are five methods. 56 00:02:12,600 --> 00:02:14,966 That we're going to discuss of building. 57 00:02:14,966 --> 00:02:15,733 Models. 58 00:02:15,733 --> 00:02:17,766 Number one is all in. 59 00:02:17,766 --> 00:02:19,166 Number two is backward. 60 00:02:19,166 --> 00:02:20,000 Elimination. 61 00:02:20,000 --> 00:02:22,566 Number three is forward selection. 62 00:02:22,566 --> 00:02:25,500 Number four is bidirectional elimination. 63 00:02:25,500 --> 00:02:28,233 And number. Five is score. Comparison. 64 00:02:28,233 --> 00:02:29,100 We're going to talk about. 65 00:02:29,100 --> 00:02:31,100 Each one of them just now. 66 00:02:31,100 --> 00:02:32,700 Before we do I wanted to say that. 67 00:02:32,700 --> 00:02:35,666 Sometimes you'll hear. Stepwise regression. 68 00:02:35,666 --> 00:02:40,900 So stepwise regression actually refers to number two three and four. 69 00:02:41,666 --> 00:02:46,433 because those are like really the true step by step methods. but. 70 00:02:46,433 --> 00:02:49,466 Sometimes you will hear people say stepwise stepwise. 71 00:02:49,466 --> 00:02:51,933 Regression in reference. To just number four. 72 00:02:51,933 --> 00:02:54,433 So they will replace B bidirectional. 73 00:02:54,433 --> 00:02:57,000 Elimination. With stepwise regression. 74 00:02:57,000 --> 00:02:58,266 And that's fine. 75 00:02:58,266 --> 00:03:00,133 That's that's normal. That's just. Because. 76 00:03:01,233 --> 00:03:02,800 That's the more as you'll see. 77 00:03:02,800 --> 00:03:03,266 From what we. 78 00:03:03,266 --> 00:03:07,066 Discussed, bidirectional elimination is kind of the more general approach. 79 00:03:07,066 --> 00:03:10,466 And when people say stepwise regression, they kind of by default 80 00:03:10,900 --> 00:03:14,333 infer imply, imply 81 00:03:14,333 --> 00:03:17,433 that is bi directional elimination and you have to infer it from there. 82 00:03:18,100 --> 00:03:18,900 okay. 83 00:03:18,900 --> 00:03:21,900 So let's move on to our methods. 84 00:03:21,933 --> 00:03:22,900 Method number one. 85 00:03:22,900 --> 00:03:24,900 All in. It's not a technical term. 86 00:03:24,900 --> 00:03:26,233 I just call it offline. 87 00:03:26,233 --> 00:03:29,100 Basically what it means is just throw in all your variables. 88 00:03:29,100 --> 00:03:31,133 Something we just discussed we shouldn't do. 89 00:03:31,133 --> 00:03:33,933 When would you do that? One is if you have prior. Knowledge. 90 00:03:33,933 --> 00:03:36,600 If you know that these exact variables. 91 00:03:36,600 --> 00:03:37,500 Are the ones are. 92 00:03:37,500 --> 00:03:40,600 Your true predictors, you don't have to build anything. 93 00:03:40,600 --> 00:03:43,500 You already know that this is the case. 94 00:03:43,500 --> 00:03:43,866 You might. 95 00:03:43,866 --> 00:03:47,066 Know it from domain knowledge, or you might know it 96 00:03:47,066 --> 00:03:49,866 because you've done this model before, or somebody just. 97 00:03:49,866 --> 00:03:51,833 Gave you these variables and said, please. 98 00:03:51,833 --> 00:03:54,300 Build a model. Well, then you don't really have a choice. 99 00:03:54,300 --> 00:03:56,166 You just build the model. 100 00:03:56,166 --> 00:03:56,700 The other one. 101 00:03:56,700 --> 00:03:59,033 Is you have to perhaps, like, 102 00:03:59,033 --> 00:04:02,700 I can't really think of good examples here, but maybe there's. Some 103 00:04:03,666 --> 00:04:06,133 framework in your company that. 104 00:04:06,133 --> 00:04:08,400 Says that you have to use these variables, right? 105 00:04:08,400 --> 00:04:09,700 So it's kind of similar to. 106 00:04:09,700 --> 00:04:12,700 Prior knowledge, but it's not a, it's not. A. 107 00:04:13,200 --> 00:04:14,166 it's not your decision. 108 00:04:14,166 --> 00:04:16,400 It's you might want. To do it differently, 109 00:04:16,400 --> 00:04:20,700 but there is a framework, you know, like maybe a bank and to. 110 00:04:21,566 --> 00:04:22,000 predict. 111 00:04:22,000 --> 00:04:24,066 Credit, like the likelihood 112 00:04:24,066 --> 00:04:27,066 of somebody defaulting on something they have to use these specific variables. 113 00:04:27,866 --> 00:04:29,666 once again, I'm not sure in. 114 00:04:29,666 --> 00:04:32,666 Which industries that would be the case, but perhaps that could be the case. 115 00:04:33,300 --> 00:04:35,966 And number three, you would use this method if you're. 116 00:04:35,966 --> 00:04:39,500 Preparing for a backward elimination type 117 00:04:39,500 --> 00:04:43,433 of construction of regression, which is our next type. 118 00:04:43,433 --> 00:04:46,433 So let's move on to backward elimination 119 00:04:46,833 --> 00:04:49,100 okay. So here comes a step by step stuff. 120 00:04:49,100 --> 00:04:53,100 You might you might want to get your pens out and write these things down. 121 00:04:53,100 --> 00:04:56,366 Because we're going to have a truly step by step methanol. 122 00:04:56,700 --> 00:04:57,366 All right. 123 00:04:57,366 --> 00:04:59,266 Backward elimination. 124 00:04:59,266 --> 00:05:01,200 First thing step one. 125 00:05:01,200 --> 00:05:03,833 You have to select a significance level to. 126 00:05:03,833 --> 00:05:04,800 Stay in the model. 127 00:05:04,800 --> 00:05:07,666 So by default we're going to go with 5%. 128 00:05:07,666 --> 00:05:09,600 So 0.05. 129 00:05:09,600 --> 00:05:11,466 And we're going to use it in the next step. 130 00:05:11,466 --> 00:05:13,166 So at the beginning you. 131 00:05:13,166 --> 00:05:15,633 Decide on this significance level. 132 00:05:15,633 --> 00:05:17,266 Step two you fit the. 133 00:05:17,266 --> 00:05:19,066 Full model with all possible. Predictors. 134 00:05:19,066 --> 00:05:22,200 So you kind of do that all in approach which we just talked about. 135 00:05:22,466 --> 00:05:24,300 And you put all of your variables. 136 00:05:24,300 --> 00:05:25,333 Into your model. 137 00:05:26,400 --> 00:05:27,400 And now we're going to start. 138 00:05:27,400 --> 00:05:28,600 Getting rid of them. 139 00:05:28,600 --> 00:05:32,333 Step three you considered the predictor with the highest p value. 140 00:05:32,366 --> 00:05:34,833 So remember those p values that we talked about. 141 00:05:34,833 --> 00:05:38,233 In for instance in gretl or in any software you can see them. 142 00:05:38,500 --> 00:05:42,533 So after you've fitted the model you'll see the one with the highest p value. 143 00:05:42,933 --> 00:05:45,666 So if p is greater 144 00:05:45,666 --> 00:05:49,500 than your significance level then you go to step four. 145 00:05:49,666 --> 00:05:51,000 And step four. 146 00:05:51,000 --> 00:05:52,800 Is you have to remove that predictor. 147 00:05:52,800 --> 00:05:56,100 So remove basically the variable that has the highest p value. 148 00:05:56,433 --> 00:05:58,133 And from step. Four you. 149 00:05:58,133 --> 00:05:59,700 Fit the model without. This variable. 150 00:05:59,700 --> 00:06:02,166 So there's a star here because. 151 00:06:02,166 --> 00:06:03,300 I just wanted to remind myself. 152 00:06:03,300 --> 00:06:10,800 To tell you that if you just remove the variable, obviously you can't just say. 153 00:06:10,800 --> 00:06:11,300 That okay. 154 00:06:11,300 --> 00:06:12,833 Now now I've got the new model. 155 00:06:12,833 --> 00:06:14,333 You have to actually refit them all. 156 00:06:14,333 --> 00:06:17,766 You have to re recreate the model, rebuild it with the. 157 00:06:17,766 --> 00:06:20,133 Fewer number of. Variables. So if you had. 158 00:06:20,133 --> 00:06:23,200 Maybe I don't know, 100 variables and you removed them, one of them 159 00:06:23,200 --> 00:06:25,566 you have 99 now. Well you have to rebuild it. 160 00:06:25,566 --> 00:06:27,700 So the coefficients are going to be different. 161 00:06:27,700 --> 00:06:29,700 The constant is going to be different. 162 00:06:29,700 --> 00:06:32,600 And you need to perform that step. 163 00:06:32,600 --> 00:06:35,100 Because once you remove a variable it affects. 164 00:06:35,100 --> 00:06:38,100 All the other variables in your whole regression. 165 00:06:38,633 --> 00:06:41,633 And so after step five you go back to step three. 166 00:06:41,766 --> 00:06:45,800 Once again you look for the variable with the highest p value in. 167 00:06:45,800 --> 00:06:49,233 Your new model. You take it out, you remove. 168 00:06:49,266 --> 00:06:51,133 So basically step four you remove it. 169 00:06:51,133 --> 00:06:51,666 You fit the. 170 00:06:51,666 --> 00:06:54,433 Model again with one less variable and so on. 171 00:06:54,433 --> 00:06:57,933 You keep doing that until you come to a point where 172 00:06:58,500 --> 00:07:01,500 though even the variable with the highest p value 173 00:07:01,733 --> 00:07:05,600 that's p value is still less than your significance level. 174 00:07:05,600 --> 00:07:07,400 So if that condition p is greater. 175 00:07:07,400 --> 00:07:09,833 Than SL is not correct. 176 00:07:09,833 --> 00:07:11,800 Then you don't go to step four anymore. 177 00:07:11,800 --> 00:07:13,433 You go to Finn. 178 00:07:13,433 --> 00:07:16,100 In this case, Finn is the finish. 179 00:07:16,100 --> 00:07:17,666 Your model is ready. 180 00:07:17,666 --> 00:07:21,400 So as soon as all of the variables that you have left in your. 181 00:07:21,766 --> 00:07:23,333 Model are. 182 00:07:23,333 --> 00:07:24,366 There, p values are. 183 00:07:24,366 --> 00:07:26,200 Less than the significance level. 184 00:07:26,200 --> 00:07:27,666 Your models prepared. 185 00:07:28,866 --> 00:07:31,200 So that's how the backward elimination method works. 186 00:07:31,200 --> 00:07:32,700 Let's move on to the next one. 187 00:07:32,700 --> 00:07:35,166 Next method is the forward selection. 188 00:07:35,166 --> 00:07:35,733 This is. 189 00:07:35,733 --> 00:07:36,933 It sounds like the opposite 190 00:07:36,933 --> 00:07:40,100 on the picture in the top right corner does illustrate the opposite. 191 00:07:40,433 --> 00:07:44,566 But it's much more complex than just simply reversing. 192 00:07:44,866 --> 00:07:45,566 the. 193 00:07:45,566 --> 00:07:48,533 Procedure you will see that it's it's a much. 194 00:07:48,533 --> 00:07:50,266 Larger. Procedure. 195 00:07:50,266 --> 00:07:52,200 We started with step one. 196 00:07:52,200 --> 00:07:55,233 Select a significance level to enter the model. 197 00:07:55,766 --> 00:07:58,766 And in this case once again we're going to select 5%. 198 00:07:59,700 --> 00:08:00,833 Then we go to step two. 199 00:08:00,833 --> 00:08:04,766 We fit all possible simple regression models. 200 00:08:04,766 --> 00:08:06,900 So we take. 201 00:08:06,900 --> 00:08:08,600 The dependent variable. 202 00:08:08,600 --> 00:08:09,333 And we create a. 203 00:08:09,333 --> 00:08:11,700 Regression model with every single independent. 204 00:08:11,700 --> 00:08:13,333 Variable that we have. 205 00:08:13,333 --> 00:08:16,433 And then we select out of all those models we select the. One. 206 00:08:16,633 --> 00:08:18,966 Which has the lowest p value for. 207 00:08:18,966 --> 00:08:20,366 The independent variable. 208 00:08:21,633 --> 00:08:24,266 So you can already see that that is by in itself. 209 00:08:24,266 --> 00:08:25,200 A lot of. Work. 210 00:08:25,200 --> 00:08:27,466 Then what we do is we move to step three. 211 00:08:27,466 --> 00:08:30,400 We keep this variable that we've just, 212 00:08:30,400 --> 00:08:32,866 chosen, and we fit all. 213 00:08:32,866 --> 00:08:35,466 Other possible models with one extra. 214 00:08:35,466 --> 00:08:39,333 Predictor added to the one you already have. 215 00:08:39,333 --> 00:08:41,133 So what does that mean? 216 00:08:41,133 --> 00:08:44,533 That means we've selected a, Simple. 217 00:08:45,000 --> 00:08:46,200 Linear regression. 218 00:08:46,200 --> 00:08:47,500 With one variable. 219 00:08:47,500 --> 00:08:50,500 Now we need to construct all possible. 220 00:08:51,500 --> 00:08:54,733 Linear regressions with two variables where one of those two 221 00:08:54,733 --> 00:08:56,400 variables is the one over you selected. 222 00:08:56,400 --> 00:08:57,033 So basically we. 223 00:08:57,033 --> 00:08:59,066 Add on 224 00:08:59,066 --> 00:09:01,766 all possible all of the other variables one by. One. 225 00:09:01,766 --> 00:09:04,633 So we choose okay. Let's add on this variable. 226 00:09:04,633 --> 00:09:07,266 And then let's add on the next one like but separately. 227 00:09:07,266 --> 00:09:12,066 So we construct all possible two variable linear regressions. 228 00:09:12,533 --> 00:09:13,766 And just keeping. 229 00:09:13,766 --> 00:09:16,433 Definitely keeping the variable that. We've already selected. 230 00:09:16,433 --> 00:09:17,666 So what do we do after that. 231 00:09:18,800 --> 00:09:19,466 Out of all. 232 00:09:19,466 --> 00:09:24,333 Of these possible two variable regressions, we consider the. One. 233 00:09:24,700 --> 00:09:28,633 Where the new variable that we added had the lowest p value. 234 00:09:29,666 --> 00:09:32,233 So if that p value is. 235 00:09:32,233 --> 00:09:35,733 Less than our significance level meaning that you know 236 00:09:35,733 --> 00:09:39,000 that variable is a good one, it's it's, it's a significant variable. 237 00:09:39,000 --> 00:09:40,966 Then we move back to step three. 238 00:09:40,966 --> 00:09:41,700 What does that mean? 239 00:09:41,700 --> 00:09:42,566 It means that. 240 00:09:42,566 --> 00:09:45,300 Now we have a regression with two variables. 241 00:09:45,300 --> 00:09:47,266 And now we will add a third variable. 242 00:09:47,266 --> 00:09:49,400 We'll try all possible. 243 00:09:49,400 --> 00:09:51,133 Variables that we have left as. 244 00:09:51,133 --> 00:09:52,500 Our third variable. 245 00:09:52,500 --> 00:09:54,733 And then out of all of those models. 246 00:09:54,733 --> 00:09:57,400 With three variables we will go to step four. And we'll select. 247 00:09:57,400 --> 00:09:58,966 Again the one with the. 248 00:09:58,966 --> 00:10:01,200 Lowest p value for that third variable. 249 00:10:01,200 --> 00:10:02,166 That we added. 250 00:10:02,166 --> 00:10:03,133 And we'll keep doing that. 251 00:10:03,133 --> 00:10:05,500 So basically we'll keep growing the regression. 252 00:10:05,500 --> 00:10:08,266 Model but not just random. And it will be. Actually selecting. 253 00:10:08,266 --> 00:10:11,500 Out of the old all of the possible combinations every single time 254 00:10:12,300 --> 00:10:15,233 and growing it one variable at a time. 255 00:10:16,200 --> 00:10:18,333 And then we will only stop. 256 00:10:18,333 --> 00:10:23,566 When the variable that we've added it has a p value that is. 257 00:10:23,566 --> 00:10:25,733 Greater than our significance level. 258 00:10:25,733 --> 00:10:27,633 So when. This condition P is less. 259 00:10:27,633 --> 00:10:29,666 Than SL is not true. 260 00:10:29,666 --> 00:10:30,966 Then we don't go to step three. 261 00:10:30,966 --> 00:10:32,500 We finish the regression. 262 00:10:32,500 --> 00:10:33,133 Why will. 263 00:10:33,133 --> 00:10:35,133 Because that variable that we just added. 264 00:10:35,133 --> 00:10:36,666 Is no longer. 265 00:10:36,666 --> 00:10:38,000 Is not. Significant anymore. 266 00:10:38,000 --> 00:10:38,633 And we. 267 00:10:38,633 --> 00:10:39,833 Also know that we selected. 268 00:10:39,833 --> 00:10:41,700 The one with. The lowest p value. 269 00:10:41,700 --> 00:10:44,700 So there's no other variable that we can add that. 270 00:10:44,900 --> 00:10:47,233 Its p value will be greater. 271 00:10:47,233 --> 00:10:48,766 will be less than SL. 272 00:10:48,766 --> 00:10:51,433 Any, any regression which is from. 273 00:10:51,433 --> 00:10:52,800 Then onwards. 274 00:10:52,800 --> 00:10:56,133 It will the variable, the new variable will always be insignificant. 275 00:10:56,266 --> 00:10:58,733 And so here we finish the regression. 276 00:10:58,733 --> 00:11:01,133 And the trick here is that you keep. 277 00:11:01,133 --> 00:11:03,566 Not the current model but the previous one. 278 00:11:03,566 --> 00:11:04,066 And that makes. 279 00:11:04,066 --> 00:11:08,133 Sense because you've just added a variable which is insignificant. 280 00:11:08,133 --> 00:11:10,900 So what's the point of that variable. Just move a step back. 281 00:11:10,900 --> 00:11:12,633 So that's how forward selection works. 282 00:11:12,633 --> 00:11:14,100 I know it's a bit confusing, 283 00:11:14,100 --> 00:11:17,100 but just try to wrap your head around and maybe read through these instructions. 284 00:11:17,100 --> 00:11:18,000 One more time. 285 00:11:18,000 --> 00:11:22,333 It does make a lot of sense when you and this like kind of picture, what. 286 00:11:22,666 --> 00:11:23,766 Exactly is. Going on. 287 00:11:25,466 --> 00:11:28,766 And next we're moving on to the bidirectional elimination. 288 00:11:29,100 --> 00:11:30,833 So this one, as you can. 289 00:11:30,833 --> 00:11:33,600 Assume or perhaps guess. 290 00:11:33,600 --> 00:11:34,500 It combines the two. 291 00:11:34,500 --> 00:11:35,333 Step one. 292 00:11:35,333 --> 00:11:38,500 Select a significance level to stay or to enter. 293 00:11:38,500 --> 00:11:40,800 And a. Significance. Level to. Stay. 294 00:11:40,800 --> 00:11:43,666 So we're going to select in both cases 5%. 295 00:11:43,666 --> 00:11:46,300 But it's up to you what you select. 296 00:11:46,300 --> 00:11:46,866 Step two. 297 00:11:46,866 --> 00:11:49,200 Perform the next. Step of the. 298 00:11:49,200 --> 00:11:51,300 Forward selection. 299 00:11:51,300 --> 00:11:53,433 meaning that the one that. 300 00:11:53,433 --> 00:11:54,433 We just discussed. 301 00:11:54,433 --> 00:11:58,866 So where new variables, when they enter in order to enter they have to be. 302 00:11:59,166 --> 00:12:01,333 Less than the significance. 303 00:12:01,333 --> 00:12:03,033 Level two enter. 304 00:12:03,033 --> 00:12:07,266 So basically add on a new variable based on the forward selection method. 305 00:12:07,700 --> 00:12:11,300 Step three perform all of the steps of the backward elimination process. 306 00:12:11,300 --> 00:12:12,333 So now. 307 00:12:12,333 --> 00:12:15,866 If you have two variables, start getting rid of them and see if you can get rid of. 308 00:12:15,866 --> 00:12:17,400 Any of them. And then 309 00:12:18,400 --> 00:12:19,500 move back to step two. 310 00:12:19,500 --> 00:12:21,433 So then grow it by another variable. 311 00:12:21,433 --> 00:12:23,233 And every time you grow it by a variable, say let's 312 00:12:23,233 --> 00:12:26,233 let's say you were at, five variables and you went to six. 313 00:12:26,466 --> 00:12:29,566 Since you went to six, you have to from all of the steps of backward elimination. 314 00:12:29,566 --> 00:12:30,966 So you don't just. Eliminate one variable. 315 00:12:30,966 --> 00:12:32,466 If you can eliminate one, two. 316 00:12:32,466 --> 00:12:34,633 Three, however many you can. 317 00:12:34,633 --> 00:12:37,266 And then from there you can go back to step two. 318 00:12:37,266 --> 00:12:39,133 And so this is a very iterative process. 319 00:12:39,133 --> 00:12:40,200 You keep doing that. 320 00:12:40,200 --> 00:12:42,333 Until at some. Point you cannot. 321 00:12:42,333 --> 00:12:43,666 Add new variables. 322 00:12:43,666 --> 00:12:46,833 No variables can enter or no old variables can exit. 323 00:12:46,833 --> 00:12:50,733 And as soon as you get there, then you proceed to the finish because. 324 00:12:50,733 --> 00:12:52,400 Your model is. Ready. 325 00:12:52,400 --> 00:12:54,466 You can't you can't add anything. You can't take anything out. 326 00:12:54,466 --> 00:12:57,000 That means you've, you've created the model. 327 00:12:57,000 --> 00:12:58,833 So this. Is one of the more. 328 00:12:58,833 --> 00:13:00,433 Tedious methods. 329 00:13:00,433 --> 00:13:02,066 Of course, you would have to, 330 00:13:02,066 --> 00:13:06,033 get a computer to do this for you, because otherwise you'd go go insane. 331 00:13:06,400 --> 00:13:08,300 Putting variables in and taking them out. 332 00:13:08,300 --> 00:13:11,266 But that's how bidirectional elimination works. 333 00:13:11,266 --> 00:13:15,233 and once again, some people call it 334 00:13:15,533 --> 00:13:20,500 stepwise regression and finally all possible models. 335 00:13:20,766 --> 00:13:21,666 So this is. 336 00:13:21,666 --> 00:13:27,566 The most probably thorough approach, but also the most, resource. 337 00:13:27,566 --> 00:13:31,400 Consuming approach because you select a criterion of goodness of fit. 338 00:13:31,400 --> 00:13:34,400 For instance, like chi key criterion can be the R squared. 339 00:13:34,566 --> 00:13:35,533 lots of different criteria. 340 00:13:35,533 --> 00:13:38,600 And then you construct all possible regression model. 341 00:13:38,600 --> 00:13:40,533 So if you had. And variables then. 342 00:13:40,533 --> 00:13:42,033 There will be a two. 343 00:13:42,033 --> 00:13:44,966 To the power of n minus one total combinations. 344 00:13:44,966 --> 00:13:45,700 Of these variables. 345 00:13:45,700 --> 00:13:49,233 And that that's exactly how many models there can possibly be. 346 00:13:50,100 --> 00:13:51,066 And then. 347 00:13:51,066 --> 00:13:53,266 Step three you select the. One of these models. 348 00:13:53,266 --> 00:13:55,500 With the best criterion. That you're looking at. 349 00:13:56,700 --> 00:13:57,133 There you go. 350 00:13:57,133 --> 00:13:58,200 Your model is ready. 351 00:13:58,200 --> 00:14:01,733 So sounds easy, but let's have a look at an example. 352 00:14:01,733 --> 00:14:02,166 Even if you have. 353 00:14:02,166 --> 00:14:05,433 Ten columns in your data, you'll have 1023 models. 354 00:14:05,433 --> 00:14:08,000 That's insane. That's an insane amount of models. 355 00:14:08,000 --> 00:14:09,800 And we're not talking about columns that. 356 00:14:09,800 --> 00:14:10,966 You've already filter. Out. 357 00:14:10,966 --> 00:14:15,000 So columns that, you, you know, that's like in our example, 358 00:14:15,000 --> 00:14:18,000 you might have 5 or 6 columns. 359 00:14:18,000 --> 00:14:21,000 Now we're talking about when you get a data set that you. 360 00:14:21,633 --> 00:14:23,433 You just it's pretty much raw. 361 00:14:23,433 --> 00:14:27,100 And it has like maybe 100 columns like I've worked with 362 00:14:27,100 --> 00:14:29,200 data sets were around that. 363 00:14:29,200 --> 00:14:32,500 Maybe 50 to 1. Hundred, maybe more columns. 364 00:14:32,700 --> 00:14:35,066 And instead of going through them, this is what this. 365 00:14:35,066 --> 00:14:36,200 Method is suggesting. 366 00:14:36,200 --> 00:14:38,266 Instead of going through them and picking out the ones that. 367 00:14:38,266 --> 00:14:40,733 You think should be in your model, you just throw. Everything in. 368 00:14:40,733 --> 00:14:43,133 Well, it's not a. Good approach because 369 00:14:44,133 --> 00:14:45,600 basically it's. 370 00:14:45,600 --> 00:14:46,866 it's growing exponentially. 371 00:14:46,866 --> 00:14:49,200 The number of models is growing exponentially. 372 00:14:49,200 --> 00:14:54,633 And, it's, It's very resource consuming to get. 373 00:14:54,633 --> 00:14:56,533 A result from this approach. 374 00:14:56,533 --> 00:14:57,900 And finally. 375 00:14:57,900 --> 00:15:00,466 So where have we come to? 376 00:15:00,466 --> 00:15:01,933 We've come to our conclusion. 377 00:15:01,933 --> 00:15:06,333 We have five methods of building model models, all in backward elimination. 378 00:15:06,333 --> 00:15:06,966 For selection. 379 00:15:06,966 --> 00:15:09,866 Bidirectional elimination and score comparison. 380 00:15:09,866 --> 00:15:14,700 So the one we're going to be looking at in these tutorials, in order to get. 381 00:15:14,700 --> 00:15:16,000 Our head around. 382 00:15:16,000 --> 00:15:19,600 How to build models step by step and get some practice, is the backward. 383 00:15:19,600 --> 00:15:21,933 Elimination. Process because it is the. 384 00:15:21,933 --> 00:15:23,633 Fastest one at all of them. 385 00:15:23,633 --> 00:15:26,833 And you will still get to see exactly how the step by. 386 00:15:26,833 --> 00:15:28,033 Step method works. 387 00:15:28,033 --> 00:15:28,733 And plus, we'll. 388 00:15:28,733 --> 00:15:31,833 Throw in a few extra tricks along the way to make sure. 389 00:15:31,833 --> 00:15:34,833 Our models are very robust. 390 00:15:35,166 --> 00:15:36,800 Can't wait to get started! 391 00:15:36,800 --> 00:15:37,800 Lots of theory. 392 00:15:37,800 --> 00:15:40,466 Let's get to the practice. I'll look forward to seeing you next time.