Visualizing Model Predictions Workout
- 01:04
How to use a lasso model for making predictions and visualizing results with a scatter plot, and comparing predicted values against actual values from test data.
Glossary
Machine Learning Python Visualizing DataTranscript
You're simply going to plot the results of the winning gradient booster model.
I'm creating this new variable, and it has the same name as the for loop that we used before, but as an important point, when you create a variable inside a for loop that is temporary and it doesn't last outside of the for loop. So I'm creating this variable called preds, where I'm gonna store my predictions from the gradient booster model. Now I'm using the pyplot scatter function, and the pyplot scatter function takes the first argument and puts it on the X axis, and it takes the second argument and puts it on the Y axis. So my predictions will be on the X axis and then the correct answer that target testing data will be on the Y axis. I am labeling my X label as predicted, and my Y label as actual, so that this is obvious when people are looking at it. And then I'm using the pyplot show function to display. As you see here, the predictions of the gradient model are far more accurate than the predictions of the lasso model.