3
3
# Data
data = {
'weight': [140, 155, 159, 179, 192, 200, 212],
'height': [60, 62, 67, 70, 71, 72, 75]
}
# Create DataFrame
df = pd.DataFrame(data)
# Predictions
predictions = model.predict(X)
# Plotting
plt.scatter(df['weight'], df['height'], color='blue', label='Data points')
plt.plot(df['weight'], predictions, color='red', linewidth=2, label='Linear␣
↪regression line')
plt.xlabel('Weight in lbs')
plt.ylabel('Height in inches')
plt.title('Linear Regression Model')
plt.legend()
plt.show()
1
2