Hello and welcome to this art tutorial.
So in this tutorial, we're not going to make any machine learning model.
We're just going to make a template.
And this will be our regression template.
So it's a template that is going to be very useful
for the next non-linear regression models we are going to make.
And also you can use this template to create a regression
model for your specific problem.
Because as you can see, you will only have a few things to change
so that you will build your machine learning model very efficiently.
So let's make this template and to make it we're going to go
from what we did in polynomial regression and generalized the whole thing.
So I'm going to take everything from here up to the end copy.
And I'm going to paste that in the template.
And now let's make this template okay.
So first of all let's start with the beginning.
So the beginning was about pre-processing the data.
So actually there is nothing to change here.
We will keep of course these two lines because we will work on the position
salary CSV file and build our non-linear regression models on it.
And for the same reason as before, we will need to split the data
set into a training set and a test set, because this is a small data set
and we will leave feature scaling as comments here, since
most of the libraries don't require us to apply feature scaling manually.
So all good for the pre-processing phase.
And this will be the first part of our regression template.
Great. Now let's move on to the next part.
So the next part is about creating the model,
creating the model, and fitting it to the data set.
So first of all, in the previous tutorial we built two regression models
the linear regression model and the polynomial regression model.
And that was just
to compare the two results and to show you that the polynomial regression model
was much more appropriate to our problem because it was non-linear regression
model as opposed to the linear regression model, which is a linear model.
So we only did that so that you can understand very clearly
the distinction between linear models and non-linear models.
But now that it's getting pretty clear in our mind,
we are going to get rid of this section here about linear regression.
Because now we get the idea and we will only focus
on the new non-linear regression models themselves
without comparing them to the linear regression model.
But to keep the graphic results of the linear regression model in mind,
keep in mind that it was a straight line, not fitting very well to data set,
and therefore was not much appropriate to our data set.
Where the data is non-linearly distributed.
Okay, so we're going to get rid of this done.
Now we only have this code section here that creates the non-linear regression
model itself.
So we're going to get rid of this
because this corresponds to the polynomial regression.
And to generalize we will just add a come here
to specify that this is where we have to create our
regressor right here okay.
And here we can also replace polynomial regression
by the regression model.
And we are all good with this section okay.
Now let's move on to the next one.
The next one is about visualizing the results.
So for the same reason as what we did in this section,
to fit the regression model to the data set,
we will get rid of the graphic results of the linear regression model
because we have them in mind,
and we only want to focus on our future non-linear regression models.
So let's get rid of this.
And now we only have the graphic results
of our future non-linear regression model okay.
And the great thing about this template
is that in this section we won't need to change anything.
Well, almost anything because we're going to replace
polynomial regression by regression model.
And we are going to change
this poly rag regressor here by regressor.
Because you know before we called it poly rag because we also had our linear
regressor linear.
And so we needed to make the distinction.
But now since we got rid of the linear regression model,
we will call our future non-linear regression model regressor here.
And that's why we input two regressor here and the predict function.
So basically when we get to this section, when we build our future
non-linear regression model,
the only thing that we will need to change is actually the title here.
Basically we don't have anything to change here.
And that's the great thing about this template.
However, of course, if you're using this template on your data
set in your problem, well, the only thing that you will need to change
are the names here.
The independent variable, and also the name of the dependent variable here.
That is, you'll have to replace salary by the name of your dependent variable.
But that's all okay.
And we are finally getting to the last section of this code template,
which is about predicting the final result to get our final verdict.
Okay, so same reason as before.
We're going to get rid of the linear regression part for this.
So here we go.
Good bye.
And now we are only left with the polynomial regression prediction
okay great.
And so now we just need to change something here.
Well first it's the name of the regressor.
Because before the name of our polynomial regression regressor was called poly rag.
And now since we won't make the distinction
between a linear regression model and our non-linear regression model,
well, our regressor will be called regressor.
So here regressor and here you know for polynomial regression we need to input
the polynomial features of our data frame that we created in our data frame.
Well we won't need to do this for the next non-linear models
because this is strictly specific to the polynomial regression model
where you know we need to add those polynomial features.
And so we will get rid of this and we'll get something very simple.
It's actually this line that will perfectly predict
the salary of this 6.5 position level.