Issue
I'd like to make comparing this Prediction and Test values easier, so I'm thinking two ways to achieve that:
- Scale the X and Y axis to the same scale
- Plot a linear line (y=x)
- Really like to have some way to either 'exclude' the outliers or perhaps 'zoom in' to the area where the points are dense, without manually excluding the outliers from the dataset (so its done automatically). Is this possible?
sns.scatterplot(y_pred, y_true)
plt.grid()
Looked around and tested plt.axis('equal')
as mentioned on another question but it didn't seem quite right. Tried using plt.plot((0,0), (30,30))
to create the linear plot but it didn't show anything. Any other input on how to visualise this would be really appreciated as well. Thanks!
Solution
There are short ways to achieve everything you've suggested:
- Force scaled axes with
matplotlib.axes.Axes.set_aspect
. - Add an infinite line with slope 1 through he origin with
matplotlib.axes.Axes.axline
- Set your plot to interactive mode, so you can pan and zoom. The way to do this depends on your environment and is explained in the docs.
Best to combine them all.
import matplotlib.pyplot as plt
from numpy import random
plt.ion() # activates interactive mode in most environments
plt.scatter(random.random_sample(10), random.random_sample(10))
ax = plt.gca()
ax.axline((0, 0), slope=1)
ax.set_aspect('equal', adjustable='datalim') # force equal aspect
Answered By - Joooeey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.