So now let's move on to the next code template.
Polynomial regression.
Well here that's the same, you know the same data preprocessing phase
with first importing the libraries, then importing the data sets
where you only have to enter the name of your data set here,
and then splitting the data set into the training set and test set.
Then of course, we train the polynomial regression model on the training set.
So that's exactly like what we did in this part two.
You know when we built it you recognize degree equals four.
You know that's exactly the same code.
Then we predict some test results just to compare our predictions
and the real results.
And finally we will evaluate the model performance.
And I will reveal very soon how to do that.
Okay.
So that's for polynomial regression.
Once again very generic.
You just have to enter here the name of your data set.
And then this code template is ready to be deployed.
All right then support vector regression.
So here that's the same.
First the data preprocessing phase where we import the libraries.
Then we import the data set.
But then remember we have to reshape
our dependent variable vector y because we have two features.
Kill it. Right. Because we were doing regression.
So the dependent variable vector has continuous numerical values.
And therefore for SVR we need to scale the dependent variable vector.
That's exactly the same as what we saw together when building the SVR model.
Then I added this.
Of course, in order to split the data set into the training set and test set
so that we can indeed evaluate
the performance of SVR and compare it to the other models,
then of course, we have feature scaling compulsory for the SVR
with remember our two scalars, one
for the matrix of features and one for the dependent variable vector.
Then we train, of course the SVR model on the training set.
You know this very well. We did it together.
Then we predicted test results just to compare and have an idea
of how good are the predictions of new observations.
And finally we will evaluate the model performance with r squared.
No worries.
We'll get to that very very soon.
So that's for the SVR then for decision tree regression.
Well exactly the same.
You know the data preprocessing phase first with no feature scaling right.
Remember we don't need feature scaling for decision trees.
So once again we only have to change the name of the data set here.
Then we split the data set into the training set and test it.
Then we train the decision tree regression model on the training set,
exactly the same as we did in our implementation.
When we built it together.
Then we predict the test result
in order to compare our predictions to the real result in Y test.
And that's in order to have a first idea of the performance.
And then of course, we will evaluate the model performance with R squared.
And finally we have the exact same data preprocessing
phase where you only have to enter the name of your data set here.
And then we train the random forest regression model on the training
set with the exact same implementation as how we did it together.
Then we predict the test result in order to get a first idea of the performance.
And finally we evaluate the model performance.
All right, so as I told you, you have purely generic code templates
which you can deploy for any of your future data sets
as long as they have first of features and last, the dependent variable.
And as long as they don't have missing data or categorical data,
in which case it's still fine.
You can use your data preprocessing toolkit, but there you go.
You have this code template, and now I'm going to show you how to evaluate
your regression models using the R-squared coefficient.
All right. So let's start with r squared.
You know that
final sale in each of the implementations evaluating the model performance.
Let's see how we're going to do this.
Well as I also want to train you on how to be independent in machine learning.
We're going to pretend once again that I actually have no idea on how
to evaluate the model performance of regression models, and therefore that
I have to go to the documentation online to figure out how to do it.
All right.
I'm just training you to be independent and quickly find an information
whenever you need it.