1 00:00:00,420 --> 00:00:08,910 So in the last video we created over Libya, as we are more than for sequel to zero point zero one. 2 00:00:10,300 --> 00:00:17,230 But how to ensure that this is the best sea which we can choose for our linear model? 3 00:00:18,100 --> 00:00:26,110 We can provide any value of sea and for each value of sea, we will get a separate model and the accuracy 4 00:00:26,320 --> 00:00:29,740 escort will be different for all such models. 5 00:00:30,700 --> 00:00:41,790 So one way is to manually change this sea so I can run the same model with sequel to one with sea equal 6 00:00:41,790 --> 00:00:51,820 to zero point one and with sequel two hundred and manually compare the accuracy results for all such 7 00:00:51,940 --> 00:00:52,570 models. 8 00:00:53,200 --> 00:00:54,610 This is a lengthy process. 9 00:00:56,440 --> 00:01:04,100 To overcome this lengthy process, we can use grid search option of a scale on here. 10 00:01:05,020 --> 00:01:05,950 We can provide. 11 00:01:06,970 --> 00:01:08,620 Different values of SI. 12 00:01:10,110 --> 00:01:15,470 And Biton will automatically run our model with all these values of see. 13 00:01:16,500 --> 00:01:22,500 And later on, we can use the best model out of this given models. 14 00:01:25,980 --> 00:01:26,970 Could do this. 15 00:01:27,090 --> 00:01:29,300 We have to use grid search c.v. 16 00:01:29,880 --> 00:01:34,420 So first we have to import grid search seewhy from Escalon modern selection. 17 00:01:35,790 --> 00:01:44,570 Now, next step is to create a dictionary in which you have to mention the name of your hyper parameter 18 00:01:45,780 --> 00:01:46,590 as a key. 19 00:01:48,400 --> 00:01:53,440 And the value it will be taking as a values of your dictionary. 20 00:01:54,890 --> 00:01:58,370 Here, since I want to change values of SI. 21 00:01:59,700 --> 00:02:05,280 I will provide see as a key and then these are the values. 22 00:02:07,510 --> 00:02:10,510 I am passing this values in the form of poll. 23 00:02:11,380 --> 00:02:16,750 You can see I have selected values from zero point zero zero one to tosing. 24 00:02:17,850 --> 00:02:22,260 So I will run my model for all these 13 values of see. 25 00:02:24,080 --> 00:02:31,040 If I want to change and the other hyper parameter, I can just broyd another key value pair. 26 00:02:32,690 --> 00:02:36,100 Now, we have created a weather parameter dictionary. 27 00:02:36,800 --> 00:02:42,560 The method of using grid search is almost similar to that of training a model. 28 00:02:43,580 --> 00:02:45,170 There is one additional step. 29 00:02:45,620 --> 00:02:49,850 First, we need to clear the model that we are going to use in grid search. 30 00:02:50,180 --> 00:02:57,530 So suppose if we are using support vector classification, we have to create an object for support vector 31 00:02:57,530 --> 00:03:00,470 classification, a field using linear regression. 32 00:03:00,500 --> 00:03:03,020 We have to create an object for linear regression. 33 00:03:03,350 --> 00:03:09,650 If we are using support vector regression, we have to create an object for support vector regression. 34 00:03:10,640 --> 00:03:13,070 So first, the surplus to create that object. 35 00:03:13,760 --> 00:03:21,320 Then just like any other model training, we have to provide parameters and grid search. 36 00:03:21,470 --> 00:03:23,990 The first parameter is the word model. 37 00:03:25,490 --> 00:03:30,170 Then the second parameter is the list of parameters that we have already created. 38 00:03:32,330 --> 00:03:40,880 Note that this should be in the form of a dictionary with the parameters of your model as scheiße and 39 00:03:40,880 --> 00:03:42,860 their values as values. 40 00:03:44,450 --> 00:03:46,790 Then there are a few other parameters. 41 00:03:47,060 --> 00:03:49,280 The next parameter is and jobs. 42 00:03:50,240 --> 00:03:52,340 This should be equal to minus one. 43 00:03:53,540 --> 00:03:57,890 This is used to maximize the performance of your laptop or machine. 44 00:03:58,850 --> 00:04:05,990 So minus one means your computer or your system will use all the processing power for training this 45 00:04:05,990 --> 00:04:06,350 model. 46 00:04:07,580 --> 00:04:09,460 Then the next parameter is CV. 47 00:04:09,460 --> 00:04:11,300 CV is for cross validation. 48 00:04:12,590 --> 00:04:19,730 So if you don't know what cross-validation is, Biton will create in our model. 49 00:04:20,150 --> 00:04:21,640 All this will lose of C. 50 00:04:22,550 --> 00:04:30,650 And then it will automatically use a part of of, uh, training data to get their test result and find 51 00:04:30,650 --> 00:04:34,880 out the accuracy scored on this many values of parameter. 52 00:04:36,650 --> 00:04:38,890 So CV is ten here. 53 00:04:39,140 --> 00:04:41,660 You can change this number if you want. 54 00:04:42,260 --> 00:04:44,870 Then verbals is equal to one. 55 00:04:46,250 --> 00:04:50,420 This represents the amount of message we are going to get. 56 00:04:50,540 --> 00:04:52,460 While we are training or model. 57 00:04:54,140 --> 00:04:58,820 So you saw that we received messages in our output. 58 00:04:59,750 --> 00:05:00,990 So a few give. 59 00:05:01,040 --> 00:05:01,580 What was it? 60 00:05:01,610 --> 00:05:05,220 Well, the one you will get some message while you're cleaning your data. 61 00:05:06,020 --> 00:05:07,930 And the next parameter is scoring. 62 00:05:08,060 --> 00:05:12,740 Here we want to use accuracy scores of this models. 63 00:05:13,400 --> 00:05:17,360 Therefore, we are using scoring well to accuracy. 64 00:05:19,430 --> 00:05:22,600 Then the next step is just like any other model. 65 00:05:22,740 --> 00:05:26,700 We will fit this grid search object using our test, Sandrine. 66 00:05:27,790 --> 00:05:35,470 And after that, since we are training this many models, we can pick the best model and then predict 67 00:05:35,470 --> 00:05:37,330 the values of my variable. 68 00:05:38,950 --> 00:05:41,380 So let's first import the grid search. 69 00:05:42,680 --> 00:05:44,500 Cleared this paramedic study. 70 00:05:46,460 --> 00:05:50,580 Cleared this VLF, a solemn, linnear object. 71 00:05:51,180 --> 00:05:56,550 You can see that we are just using as as we see with current liquidly, too linear. 72 00:05:58,690 --> 00:05:59,170 And then. 73 00:06:00,180 --> 00:06:02,430 We are creating a of grid search object. 74 00:06:05,400 --> 00:06:07,980 If you want more details on the parameters. 75 00:06:09,040 --> 00:06:12,850 You can open the documentation of Eskil and Grid Search. 76 00:06:12,880 --> 00:06:15,540 You will get all the information there as well. 77 00:06:17,830 --> 00:06:20,470 Then the next, the surplus to Fethullah data. 78 00:06:21,610 --> 00:06:27,150 Remember to use standard X data instead of just X variable. 79 00:06:31,110 --> 00:06:33,810 Now, you can see we are getting this kind of messages. 80 00:06:33,990 --> 00:06:36,750 This is because we have used verbal sequel to one. 81 00:06:39,320 --> 00:06:45,920 You can see we have provided turbin values of see, that's what we are getting, the message that we 82 00:06:45,920 --> 00:06:49,340 are fitting then for we model for 13 candidates. 83 00:06:49,850 --> 00:06:52,430 For you to send for cross-validation, equate to 10. 84 00:06:55,420 --> 00:06:56,830 This may take some time. 85 00:07:01,260 --> 00:07:07,800 You can see that we have fitted our models now grid search comes with different attributes. 86 00:07:08,340 --> 00:07:11,970 The first attribute here is best underscored patterns. 87 00:07:12,690 --> 00:07:15,820 This will give you the information of the best model. 88 00:07:16,030 --> 00:07:17,550 Although this 13 models. 89 00:07:19,180 --> 00:07:25,590 So if freed on this, we can get the parameter for which we are getting the best result. 90 00:07:26,470 --> 00:07:31,510 So out of all this sea values, we are getting our best preserved at sea. 91 00:07:31,610 --> 00:07:33,340 Well, two zero point five. 92 00:07:34,770 --> 00:07:38,930 So you can see that there is no need to separately run. 93 00:07:38,950 --> 00:07:40,930 You are more than for each value of sea. 94 00:07:41,620 --> 00:07:49,900 You can just provide a single Padam dictionary and grid search, do random order for all the values 95 00:07:49,900 --> 00:07:52,780 of sea that you have mentioned in badam parameter. 96 00:07:55,430 --> 00:07:58,760 The next secretary butyrate is best under score, estimate estimated. 97 00:08:00,700 --> 00:08:07,030 So with best underscore Perram, we were getting the parameter value corresponding to our best model, 98 00:08:07,990 --> 00:08:09,830 that best center scored Sumita. 99 00:08:10,900 --> 00:08:13,240 We will get our best model. 100 00:08:14,550 --> 00:08:22,440 And here we are simply saving this, our best model, as Len, as we underscore to see Alef later on. 101 00:08:22,470 --> 00:08:26,280 We will use this Lin as a swimmer, not to score CnF. 102 00:08:27,140 --> 00:08:28,850 To predict the values of this. 103 00:08:30,780 --> 00:08:31,830 Let's run this. 104 00:08:32,580 --> 00:08:35,040 So now we have a what best model? 105 00:08:35,730 --> 00:08:38,150 The model with sequel 2.5. 106 00:08:38,760 --> 00:08:39,750 And this variable. 107 00:08:41,520 --> 00:08:43,780 Now, let's find out the accuracy score. 108 00:08:43,980 --> 00:08:52,830 Here we can radically use why test and instead of providing a separate credit variable, we can directly 109 00:08:52,830 --> 00:08:54,600 use Daudt predict function here. 110 00:08:56,130 --> 00:08:57,720 So let's run this. 111 00:08:58,740 --> 00:09:02,310 The accuracy for our model is zero point five nine. 112 00:09:03,270 --> 00:09:10,790 So this is the best accuracy which we can get out of this 13 values since our data is very less. 113 00:09:11,520 --> 00:09:14,250 And we only have around 500 observations. 114 00:09:15,000 --> 00:09:19,620 That's why he a good service is not making much sense. 115 00:09:20,070 --> 00:09:25,230 And we may get accuracy score lower than our initial accuracy score. 116 00:09:26,460 --> 00:09:27,910 So don't worry about that. 117 00:09:27,930 --> 00:09:32,700 If you have large amount of data, grid search will definitely give you a better result as compared 118 00:09:32,700 --> 00:09:35,140 to some random value of parameter. 119 00:09:39,070 --> 00:09:47,050 That's so we use grid search in the next lecture, will green, a polynomial caramel SVM model.