A house price predictor
The problem
Build a regression model in plain Python that predicts house prices from a few features, and show honestly how well it works on houses it never saw.
Requirements
- Create or collect a table of at least 40 houses with at least three numeric features and one category
- Fill missing values and scale features with statistics from the training set only
- Train linear regression with gradient descent, and compare it with the least-squares formula for one feature
- Add an L2 penalty and choose λ with a validation set
- Report the test MSE and R² once, against a baseline that always predicts the mean price
Technologies
- Python
- Linear regression
- Gradient descent
- Ridge regression
Step by step
- Build the dataset and split it into training, validation and test sets.
- Write the preparation steps: median imputation, one-hot encoding and standardization.
- Train with gradient descent and check the loss falls; compare with the formula on one feature.
- Try several λ values and keep the best on validation data.
- Evaluate once on the test set and write a short report.
Expected result
A small, honest price model with its test error, its chosen λ and an explanation of its weights.
How it is evaluated
- The model beats the mean baseline on the test set
- No statistic is computed from validation or test data
- The weights are explained in plain words
- Training and validation errors are reported for each λ
Ways to improve it
- Add squared features and see whether regularization becomes more important
- Use 5-fold cross-validation instead of one validation set
- Rebuild the same pipeline in scikit-learn and compare the results