modeling_housing / model.py
jonl521's picture
Upload folder using huggingface_hub
3aaaba5 verified
import pandas as pd
from sklearn.linear_model import LinearRegression
# Sample data
data = {
"size": [800, 1000, 1200, 1500, 1800],
"bedrooms": [1, 2, 2, 3, 3],
"price": [120000, 150000, 170000, 220000, 260000]
}
df = pd.DataFrame(data)
X = df[["size", "bedrooms"]]
y = df["price"]
model = LinearRegression()
model.fit(X, y)
# Predict a new house
prediction = model.predict([[1400, 3]])
print(f"Predicted price: ${prediction[0]:,.0f}")