Lesson 14 of 18 · 2 min
Visualize Actual vs Predicted
import matplotlib.pyplot as plt
plt.figure(figsize=(8, 6))
plt.scatter(y_test, y_pred, alpha=0.3, color='steelblue')
plt.plot([y_test.min(), y_test.max()], [y_test.min(), y_test.max()], 'r--', linewidth=2)
plt.xlabel("Actual Price")
plt.ylabel("Predicted Price")
plt.title("Actual vs Predicted — California Housing")
plt.tight_layout()
plt.show()
# Points close to red diagonal line = good predictions
