Untitled
unknown
plain_text
9 months ago
738 B
3
Indexable
import numpy as np
import matplotlib.pyplot as plt
# Define values for ln(sqft)
ln_sqft = np.linspace(5, 8, 100) # Assuming ln(sqft) ranges from 5 to 8
# Regression equations
ln_hprice_non_colonial = -0.677 + 0.815 * ln_sqft
ln_hprice_colonial = (-0.677 + 0.054) + 0.815 * ln_sqft
# Plot the regression lines
plt.figure(figsize=(8, 6))
plt.plot(ln_sqft, ln_hprice_non_colonial, label="Non-Colonial", linestyle="--", color="blue")
plt.plot(ln_sqft, ln_hprice_colonial, label="Colonial", linestyle="-", color="red")
# Labels and title
plt.xlabel("ln(Square Feet)")
plt.ylabel("ln(House Price)")
plt.title("Regression Lines for Colonial vs Non-Colonial Houses")
plt.legend()
plt.grid(True)
# Show plot
plt.show()Editor is loading...
Leave a Comment