# Lesson 1: your first model - predict a flat's price from its area
import pandas as pd
from sklearn.linear_model import LinearRegression

flats = pd.read_csv("flats.csv")
pune = flats[flats["city"] == "Pune"]

X = pune[["area_sqft"]]          # input (feature): always a table, so double brackets
y = pune["price_lakh"]           # answer (target)

model = LinearRegression()
model.fit(X, y)                  # "learning" = finding the best line through the points

print(f"Each extra sq ft adds about Rs {model.coef_[0] * 100000:,.0f}")
print(f"Starting value (intercept): {model.intercept_:.1f} lakh")
new = pd.DataFrame({"area_sqft": [650, 1000, 1500]})
for area, p in zip(new["area_sqft"], model.predict(new)):
    print(f"{area} sq ft -> predicted {p:.1f} lakh")
