Welcome back.
We calculated the metrics MSE and R squared score.
Now let's create a scatter plot with regression line to visualize how well your model fits the test
data.
Okay, so at first let me start with PLT dot figure.
Figure size is 8.5.
Let me create a scatter.
So eight by five eight inches wide and five inches tall.
Plot scatter x test y test color blue and label actual and another scatter x test y predict.
You see guys, I am using Xtest input feature and y test which is the actual target values.
Then I used x test.
And why predict y predicts for model's predictions.
Okay, so Plitt predicted values as red x marks.
So here we have red.
Let me make a note.
This plots the predicted values as red x marks and here as blue dots.
So the actual values are in blue.
The predicted values are in red.
Okay.
So we're going to display a graph that gives us the red dots as predicted and the blue dots as actual.
And we're going to see the difference and how well the predicted is similar or is closer or is far or
different from the actual data.
Then plotting start plotting with X, test y predict color red line width two and label fitted line.
This connects predicted values with a red line and shows the regression line curve that your model learned.
Now let's add the title and the label for our graph.
Plot title.
Actual versus predicted prices x label size square 1000 square meter.
Plot the y label y axis as the price and plot legend grid true and show the plot.
Let's run and here we go.
This is our amazing result.
The red line is the predicted.
You can see the legend here.
Red line is the predicted actual price is the blue dots as the points evenly distributed around the
line.
Also clear linear relationship.
And as the blue dots close to the red line as you get a good fit and a good result.
So as those line, close those blue dots closer cut.
We have this legend.
Actual dots are in blue that predicted in in X and the fitted line here.
So as we get closer to the red line as we get a good fit.
So the blue lines actual close to red line, which is the predicted points evenly distributed around
the line and clear linear relationship.
This is a good result.
So here I want from you to understand this note.
For the good results you should get for good results.
As I told you, you should get the blue dots close to the red line.
So you can see those blue dots are close to the red line points evenly distributed around the line.
Also we have evenly distributed points clear linear relationship.
So we can see that we are following linear line.
So this is the straight line.
If we get blue dots far from red line.
Curved pattern in residuals points clustered in certain areas you get poor fit and bad results.
So you should get those symptoms, those indications, the blue dots close to red line points evenly
distributed around the line, and the clear linear relationship in order to get a good result for your
model.