Visualizing Model Predictions
- 01:22
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.
Downloads
No associated resources to download.
Glossary
Machine Learning Python Visualizing DataTranscript
You can visualize your results using the pyplot scatter function. As you can see here, I'm creating this predictions object and setting it equal to the predictions from my lasso model. Then I'm using the pyplot PLT scatter function, and the first argument is my predictions, and the second argument is my target values from my test data. Finally, I'm labeling my axes and then showing the graphs, so PLT for pyplot and I'm calling my X label predicted and my Y label actual to match the arguments that I just gave that scatter function, my prediction, and my target values. Then finally, I'm using the pyplot show function to display the graph, and you can see here that I have my predictions on the X axis and my actual values on the Y axis. So looking at this graph, a perfect prediction would follow the line of one-to-one, because one-to-one would mean my prediction is equal to the actual values. You can see here it's a little bit of a shotgun spread with the lasso model, which we would expect because it explains less than half of the variation in our target variable based on that R squared, you should get a different result when you look at your decision tree models, which you'll do in this upcoming exercise.