1 00:00:00,100 --> 00:00:02,166 Hello and welcome to this art tutorial. 2 00:00:02,166 --> 00:00:05,133 So in this tutorial, we're not going to make any machine learning model. 3 00:00:05,133 --> 00:00:07,400 We're just going to make a template. 4 00:00:07,400 --> 00:00:09,766 And this will be our regression template. 5 00:00:09,766 --> 00:00:12,200 So it's a template that is going to be very useful 6 00:00:12,200 --> 00:00:15,233 for the next non-linear regression models we are going to make. 7 00:00:15,466 --> 00:00:19,000 And also you can use this template to create a regression 8 00:00:19,000 --> 00:00:21,233 model for your specific problem. 9 00:00:21,233 --> 00:00:24,266 Because as you can see, you will only have a few things to change 10 00:00:24,433 --> 00:00:27,433 so that you will build your machine learning model very efficiently. 11 00:00:28,100 --> 00:00:31,166 So let's make this template and to make it we're going to go 12 00:00:31,166 --> 00:00:35,800 from what we did in polynomial regression and generalized the whole thing. 13 00:00:36,000 --> 00:00:40,366 So I'm going to take everything from here up to the end copy. 14 00:00:40,866 --> 00:00:43,166 And I'm going to paste that in the template. 15 00:00:43,166 --> 00:00:46,666 And now let's make this template okay. 16 00:00:46,666 --> 00:00:48,966 So first of all let's start with the beginning. 17 00:00:48,966 --> 00:00:51,633 So the beginning was about pre-processing the data. 18 00:00:51,633 --> 00:00:53,633 So actually there is nothing to change here. 19 00:00:53,633 --> 00:00:57,000 We will keep of course these two lines because we will work on the position 20 00:00:57,000 --> 00:01:00,566 salary CSV file and build our non-linear regression models on it. 21 00:01:00,766 --> 00:01:03,600 And for the same reason as before, we will need to split the data 22 00:01:03,600 --> 00:01:07,266 set into a training set and a test set, because this is a small data set 23 00:01:07,266 --> 00:01:10,433 and we will leave feature scaling as comments here, since 24 00:01:10,433 --> 00:01:14,733 most of the libraries don't require us to apply feature scaling manually. 25 00:01:15,366 --> 00:01:17,866 So all good for the pre-processing phase. 26 00:01:17,866 --> 00:01:21,400 And this will be the first part of our regression template. 27 00:01:21,900 --> 00:01:24,000 Great. Now let's move on to the next part. 28 00:01:24,000 --> 00:01:27,000 So the next part is about creating the model, 29 00:01:27,266 --> 00:01:30,166 creating the model, and fitting it to the data set. 30 00:01:30,166 --> 00:01:34,000 So first of all, in the previous tutorial we built two regression models 31 00:01:34,400 --> 00:01:37,433 the linear regression model and the polynomial regression model. 32 00:01:37,433 --> 00:01:38,033 And that was just 33 00:01:38,033 --> 00:01:41,933 to compare the two results and to show you that the polynomial regression model 34 00:01:41,933 --> 00:01:46,533 was much more appropriate to our problem because it was non-linear regression 35 00:01:46,533 --> 00:01:50,400 model as opposed to the linear regression model, which is a linear model. 36 00:01:50,666 --> 00:01:54,266 So we only did that so that you can understand very clearly 37 00:01:54,266 --> 00:01:57,966 the distinction between linear models and non-linear models. 38 00:01:58,200 --> 00:02:00,566 But now that it's getting pretty clear in our mind, 39 00:02:00,566 --> 00:02:04,000 we are going to get rid of this section here about linear regression. 40 00:02:04,266 --> 00:02:07,200 Because now we get the idea and we will only focus 41 00:02:07,200 --> 00:02:10,433 on the new non-linear regression models themselves 42 00:02:10,533 --> 00:02:13,300 without comparing them to the linear regression model. 43 00:02:13,300 --> 00:02:16,333 But to keep the graphic results of the linear regression model in mind, 44 00:02:16,566 --> 00:02:20,433 keep in mind that it was a straight line, not fitting very well to data set, 45 00:02:20,733 --> 00:02:24,100 and therefore was not much appropriate to our data set. 46 00:02:24,100 --> 00:02:27,100 Where the data is non-linearly distributed. 47 00:02:27,200 --> 00:02:30,700 Okay, so we're going to get rid of this done. 48 00:02:31,433 --> 00:02:35,366 Now we only have this code section here that creates the non-linear regression 49 00:02:35,366 --> 00:02:36,533 model itself. 50 00:02:36,533 --> 00:02:38,066 So we're going to get rid of this 51 00:02:38,066 --> 00:02:41,066 because this corresponds to the polynomial regression. 52 00:02:41,233 --> 00:02:44,833 And to generalize we will just add a come here 53 00:02:44,966 --> 00:02:49,633 to specify that this is where we have to create our 54 00:02:50,933 --> 00:02:54,066 regressor right here okay. 55 00:02:54,600 --> 00:02:57,433 And here we can also replace polynomial regression 56 00:02:57,433 --> 00:03:00,433 by the regression model. 57 00:03:01,333 --> 00:03:04,133 And we are all good with this section okay. 58 00:03:04,133 --> 00:03:05,500 Now let's move on to the next one. 59 00:03:05,500 --> 00:03:08,400 The next one is about visualizing the results. 60 00:03:08,400 --> 00:03:12,133 So for the same reason as what we did in this section, 61 00:03:12,133 --> 00:03:14,400 to fit the regression model to the data set, 62 00:03:14,400 --> 00:03:18,933 we will get rid of the graphic results of the linear regression model 63 00:03:19,100 --> 00:03:20,400 because we have them in mind, 64 00:03:20,400 --> 00:03:24,366 and we only want to focus on our future non-linear regression models. 65 00:03:24,566 --> 00:03:26,666 So let's get rid of this. 66 00:03:26,666 --> 00:03:29,466 And now we only have the graphic results 67 00:03:29,466 --> 00:03:32,533 of our future non-linear regression model okay. 68 00:03:32,800 --> 00:03:34,400 And the great thing about this template 69 00:03:34,400 --> 00:03:37,200 is that in this section we won't need to change anything. 70 00:03:37,200 --> 00:03:40,200 Well, almost anything because we're going to replace 71 00:03:40,200 --> 00:03:43,133 polynomial regression by regression model. 72 00:03:45,466 --> 00:03:46,800 And we are going to change 73 00:03:46,800 --> 00:03:51,266 this poly rag regressor here by regressor. 74 00:03:51,266 --> 00:03:55,066 Because you know before we called it poly rag because we also had our linear 75 00:03:55,066 --> 00:03:56,733 regressor linear. 76 00:03:56,733 --> 00:03:58,766 And so we needed to make the distinction. 77 00:03:58,766 --> 00:04:02,100 But now since we got rid of the linear regression model, 78 00:04:02,166 --> 00:04:06,200 we will call our future non-linear regression model regressor here. 79 00:04:06,300 --> 00:04:09,500 And that's why we input two regressor here and the predict function. 80 00:04:09,900 --> 00:04:13,300 So basically when we get to this section, when we build our future 81 00:04:13,300 --> 00:04:14,900 non-linear regression model, 82 00:04:14,900 --> 00:04:19,500 the only thing that we will need to change is actually the title here. 83 00:04:19,500 --> 00:04:21,666 Basically we don't have anything to change here. 84 00:04:21,666 --> 00:04:24,666 And that's the great thing about this template. 85 00:04:24,866 --> 00:04:27,600 However, of course, if you're using this template on your data 86 00:04:27,600 --> 00:04:31,100 set in your problem, well, the only thing that you will need to change 87 00:04:31,333 --> 00:04:32,333 are the names here. 88 00:04:32,333 --> 00:04:36,600 The independent variable, and also the name of the dependent variable here. 89 00:04:36,866 --> 00:04:40,233 That is, you'll have to replace salary by the name of your dependent variable. 90 00:04:40,633 --> 00:04:41,866 But that's all okay. 91 00:04:41,866 --> 00:04:45,933 And we are finally getting to the last section of this code template, 92 00:04:46,400 --> 00:04:50,766 which is about predicting the final result to get our final verdict. 93 00:04:51,233 --> 00:04:53,300 Okay, so same reason as before. 94 00:04:53,300 --> 00:04:56,433 We're going to get rid of the linear regression part for this. 95 00:04:56,833 --> 00:04:57,866 So here we go. 96 00:04:57,866 --> 00:04:58,833 Good bye. 97 00:04:58,833 --> 00:05:02,700 And now we are only left with the polynomial regression prediction 98 00:05:03,233 --> 00:05:04,466 okay great. 99 00:05:04,466 --> 00:05:06,800 And so now we just need to change something here. 100 00:05:06,800 --> 00:05:09,600 Well first it's the name of the regressor. 101 00:05:09,600 --> 00:05:14,466 Because before the name of our polynomial regression regressor was called poly rag. 102 00:05:14,700 --> 00:05:16,633 And now since we won't make the distinction 103 00:05:16,633 --> 00:05:19,966 between a linear regression model and our non-linear regression model, 104 00:05:20,133 --> 00:05:23,133 well, our regressor will be called regressor. 105 00:05:23,333 --> 00:05:28,600 So here regressor and here you know for polynomial regression we need to input 106 00:05:28,700 --> 00:05:33,666 the polynomial features of our data frame that we created in our data frame. 107 00:05:33,900 --> 00:05:38,066 Well we won't need to do this for the next non-linear models 108 00:05:38,066 --> 00:05:42,100 because this is strictly specific to the polynomial regression model 109 00:05:42,100 --> 00:05:45,100 where you know we need to add those polynomial features. 110 00:05:45,200 --> 00:05:49,300 And so we will get rid of this and we'll get something very simple. 111 00:05:49,766 --> 00:05:53,966 It's actually this line that will perfectly predict 112 00:05:53,966 --> 00:05:57,233 the salary of this 6.5 position level.