Download model.py from jonl521/modeling_housing: direct link, hf CLI and curl.
- Browser
- Download file 453 Bytes
-
https://huggingface.co/jonl521/modeling_housing/resolve/main/model.py
- Command line
-
hf download hf://jonl521/modeling_housing/model.py
-
curl -L -o model.py https://huggingface.co/jonl521/modeling_housing/resolve/main/model.py
453 Bytes
| 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}") | |