{"id":29861156,"url":"https://github.com/antrita/predicting-house-prices-using-machine-learning","last_synced_at":"2026-04-19T02:05:32.436Z","repository":{"id":306417543,"uuid":"1026114163","full_name":"Antrita/Predicting-House-Prices-using-Machine-Learning","owner":"Antrita","description":"[WIP!] Task: Build a simple supervised machine learning regression model using the California Housing dataset from scikit-learn, evaluate it using appropriate metrics, and deploy it with a minimal Streamlit app for predicting housing prices. ","archived":false,"fork":false,"pushed_at":"2025-07-25T12:48:17.000Z","size":636,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-25T16:44:56.225Z","etag":null,"topics":["data-science","data-visualization","house-price-prediction","linear-regression","machine-learning","modelprediction","python","sklearn"],"latest_commit_sha":null,"homepage":"https://predicting-house-prices-using-machine-learning.streamlit.app/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Antrita.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-25T10:28:41.000Z","updated_at":"2025-07-25T12:48:21.000Z","dependencies_parsed_at":"2025-07-25T16:44:58.770Z","dependency_job_id":"7c14f2da-4408-4da1-8e60-feef1a7b6442","html_url":"https://github.com/Antrita/Predicting-House-Prices-using-Machine-Learning","commit_stats":null,"previous_names":["antrita/predicting-house-prices-using-machine-learning"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Antrita/Predicting-House-Prices-using-Machine-Learning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Antrita%2FPredicting-House-Prices-using-Machine-Learning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Antrita%2FPredicting-House-Prices-using-Machine-Learning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Antrita%2FPredicting-House-Prices-using-Machine-Learning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Antrita%2FPredicting-House-Prices-using-Machine-Learning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Antrita","download_url":"https://codeload.github.com/Antrita/Predicting-House-Prices-using-Machine-Learning/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Antrita%2FPredicting-House-Prices-using-Machine-Learning/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267808409,"owners_count":24147391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","data-visualization","house-price-prediction","linear-regression","machine-learning","modelprediction","python","sklearn"],"created_at":"2025-07-30T04:12:55.761Z","updated_at":"2026-04-19T02:05:32.407Z","avatar_url":"https://github.com/Antrita.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# California Housing Price Prediction\n\n[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1B0ZYjq_5Abgg2ousvNklajOcz7jrLHcx?usp=sharing)\n\n## Project Summary\nThis project implements a machine learning solution to predict housing prices in California using the California Housing dataset. The solution includes data preprocessing, exploratory data analysis, model training with hyperparameter tuning, and a user-friendly Streamlit web application for making predictions.\n\n## Features\n- **Data Analysis**: Comprehensive EDA with visualizations\n- **Models Used**: Linear Regression and Random Forest implementations\n- **Hyperparameter Tuning**: GridSearchCV for optimal model performance\n- **Criteria for Feature Extraction**: Analysis of critical factors\n- **Interactive Web App**: Streamlit interface for user-friendly UI\n\n## Installation \u0026 Usage\n\n### 1. Clone the repository\n```bash\ngit clone https://github.com/Antrita/Predicting-House-Prices-using-Machine-Learning.git\ncd california-housing-prediction\n```\n\n### 2. Installing Dependencies\n```bash\npip install -r requirements.txt\n```\n\n### 3. Run the Jupyter Notebook\n```bash\njupyter notebook housing_prediction.ipynb\n```\n\n### 4. Launch the Streamlit application\n```bash\nstreamlit run app.py\n```\n\n## Model Performance\n\n### Metrics Explanation\n- **MAE (Mean Absolute Error)**: Average prediction error in dollars\n- **MSE (Mean Squared Error)**: Average squared prediction error\n- **R² Score**: Proportion of variance explained (closer to 1 is better)\n\n### Results\n| Model | MAE | MSE | R² Score |\n|-------|-----|-----|----------|\n| Linear Regression | $53,320 | 0.5559 | 0.5758 |\n| Random Forest | $32,754 | 0.2554 | 0.8051 |\n| Random Forest (Tuned) | $32,681 | 0.2540 | 0.8062 |\n\n## Hyperparameter Tuning Details\n\n### GridSearchCV Parameters\nThe Random Forest model was optimized using GridSearchCV with the following parameter grid:\n\n```python\nparam_grid = {\n    'n_estimators': [50, 100, 200],      # Number of trees in the forest\n    'max_depth': [10, 20, None],         # Maximum depth of trees\n    'min_samples_split': [2, 5],         # Minimum samples required to split a node\n    'min_samples_leaf': [1, 2]           # Minimum samples required at a leaf node\n}\n```\n\n**Cross-validation**: 3-fold cross-validation  \n**Scoring metric**: R² score  \n**Total combinations tested**: 36 (3 × 3 × 2 × 2)\n\n### Best Parameters Found\nAfter hyperparameter tuning, the optimal parameters were:\n- **n_estimators**: 100-200 (varies by run)\n- **max_depth**: 20 or None\n- **min_samples_split**: 2-5\n- **min_samples_leaf**: 1-2\n\n## Feature Importance Analysis\n\nThe Random Forest model identified the following features as most important for predicting house prices:\n\n1. **MedInc (Median Income)**: ~40% importance - The strongest predictor\n2. **AveOccup (Average Occupancy)**: ~15% importance\n3. **Longitude**: ~15% importance - Location matters\n4. **Latitude**: ~14% importance - Location matters\n5. **HouseAge**: ~7% importance\n6. **AveRooms**: ~5% importance\n7. **Population**: ~3% importance\n8. **AveBedrms**: ~1% importance\n\n## Data Preprocessing Details\n\n### Train-Test Split\n- **Training set**: 80% of data (16,512 samples)\n- **Test set**: 20% of data (4,128 samples)\n- **Random state**: 42 (for reproducibility)\n\n### Feature Scaling\n- **StandardScaler** applied to features for Linear Regression\n- Random Forest used raw features (no scaling required)\n\n## Streamlit App Screenshot and example\n![Streamlit UI - Prediction Example](Streamlit_UI.png)\n\nGiven the UI inputs shown:\n- **MedInc**: 3.0 → $30,000 median income\n- **HouseAge**: 10.0 → 10-year-old homes\n- **AveRooms**: 6.0 → 6 rooms average\n- **AveBedrms**: 2.0 → 2 bedrooms average\n- **Population**: 1000 → Medium density\n- **AveOccup**: 5.0 → 5 people per household (higher than typical)\n- **Latitude**: 34.0 → Southern California\n- **Longitude**: -118.0 → Los Angeles area\n\n**Model Output**: $179,758.50 (±$50,000)\n\n\n## 5. Instructions for Google Colab\n\nTo run this in Google Colab:\n\n1. Create a new Colab notebook\n2. Copy the Jupyter notebook code into cells\n3. Run all cells sequentially\n4. Download the generated model files (`best_rf_model.pkl`, `scaler.pkl`)\n5. Create `app.py` locally with the Streamlit code\n6. Run the Streamlit app locally with the downloaded model files\n\n## Bonus Features Implemented\n✅ Feature importance visualization\n✅ GridSearchCV hyperparameter tuning\n✅ Model saving with joblib\n✅ Comprehensive documentation\n✅ Interactive Streamlit UI with metrics displayed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantrita%2Fpredicting-house-prices-using-machine-learning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantrita%2Fpredicting-house-prices-using-machine-learning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantrita%2Fpredicting-house-prices-using-machine-learning/lists"}