Welcome back.
We trained our model and get the learned equation.
Price equals to 2.9 times size plus 2.7.
This is the equation that it is concluded by the model when is being trained.
Go up.
If you remember we splitted the data.
20% of the data will be used for testing and 80% of the data will be used for training.
We used this 80% for training.
Now we're going to use this 20% of the data for testing.
So step number three make predictions on test data.
So here let me start testing y pred equals to model dot predict x test model dot predict is uses the
trained model to make predictions on the test data.
Set X test contains the input features for testing.
X-test contains the input features for testing.
Why predict stores the model's predicted values?
If we run, everything will work fine.
Now let's calculate the evaluation metrics.
Start with MSE equals to mean squared error y.
Test y predict the MSE mean squared error.
Measures the average squared difference between actual and predicted values.
Lower MSE better performance.
So when you get lower MSE, your uh, you're getting better performance.
Now let's calculate another thing that we're going to use for evaluating our metrics, which is the
r squared score R squared score R squared score measures how well the model explains the variance in
the data.
Higher R square equals to better performance.
The range is from minus infinity to one.
So r square equals to r squared score.
What data we need to pass the y test and the y prediction.
So we need to set the difference between predicted and the tested once.
So the actual and the predicted.
Once you see guys how we compared how we pass the data for the testing and prediction.
How to set the difference by MSE and how to calculate a measure.
How the model explains the variance in data.
So MSE we need to get lower MSE and we need to get higher R squared.
Don't worry we're going to clarify everything in the in the chart in the next couple of minutes here.
We need to print mean squared error MSE and r squared score.
Let's run our application.
Here we get the error.
We need uh the name model is not defined.
So let me go up.
And because I started the session.
So I need to run this run this, run this.
And then run this okay.
So we get mean squared error.
The MSE is 0.163.
For r squared score is 0.9507.
In order to see if you get a good result or not it depends on the data and data scale.
So in order to determine that if this MSA is good or not.
We go up and measure how many data set we have.
So in our data set we have around 100.
So 100 times 0.16 is good equals to 16% error.
Cut to see if MSA is good or not.
We need to check the target values and your data scale.
If we go up, we have 100 rows of data that are going to be tested.
So here we have 100 rows.
So generating 100 random numbers.
This is our data.
So our data is being displayed.
And here we are displaying only the first 110.
If I need to get the whole data just run the application and you can see that it is 99.
Starting from zero.
So it's 100.
Okay, so guys we are testing our data on 100.
And we get this amazing result which is 0.6 which is perfect and outstanding.
So for from 0 to 100 we get 0.6 which is good.
But I want from you to focus with me 0.63 for for data range.
For data range between 0 and 1.
It's quite quite poor 0.63 for for data between 0 and 10.
Excellent.
Ranging between 0 and 100 is outstanding.
So this is our case.
It's very good okay guys.
So this is a very important thing you should learn which is the metrics the mean and the r squared.