Scatter Plots
A scatter plot shows pairs of values as points.
Use it when you want to inspect a relationship without drawing a connected line:
- feature versus target;
- prediction versus true value;
- two measurements for each example;
- clusters or outliers.
plt.scatter(x, y)
Plot paired measurements
Inspect paired values
Ready to run.
The plot suggests that larger hours usually goes with larger score in this
tiny dataset. It does not prove a general law. It is an inspection.
Prediction versus target
A common ML scatter plot is:
plt.scatter(target, prediction)
If predictions are good, points often lie near the diagonal line y = x.
That diagonal can be drawn as a reference.
plt.plot([0, 10], [0, 10])
Watch for swapped arrays
Scatter plots can reveal a pairing mistake. If the pattern disappears after sorting or shuffling one array, the pairs may no longer match.
Which plot type is usually better for inspecting paired measurements that are not a time sequence?
Answer it first, then check.
Hint
Choose the plot that shows each (x, y) pair as an unconnected point.
Solution
Use a scatter plot. It preserves each paired measurement without implying that consecutive points form a sequence.