A small pure-Python demo project that trains a linear regression model on sample housing data and predicts house prices from common features.
- Loads sample data from CSV
- Trains a linear regression model without external dependencies
- Predicts prices from a command-line interface
- Includes unit tests for the model and data loading code
python3 -m venv .venv
source .venv/bin/activate
python -m unittest discover
python predict.py --sqft 1800 --bedrooms 3 --bathrooms 2 --age 12Example output:
Estimated price: $367,000
predict_housing_price/
├── data/
│ └── sample_housing.csv
├── housing_price/
│ ├── __init__.py
│ ├── data.py
│ └── model.py
├── tests/
│ └── test_model.py
├── predict.py
└── README.md
The model uses ordinary least squares linear regression. It adds an intercept term automatically and solves the normal equation with a small ridge fallback if the matrix is singular.