An end-to-end machine learning web application that predicts house prices with intelligent explanations using SHAP (SHapley Additive exPlanations). Built with Flask, XGBoost, and interactive visualizations.
- Multiple ML Models: Comparative analysis of 5 different algorithms (Linear Regression, Ridge, Lasso, Random Forest, XGBoost)
- Best Model Selection: XGBoost chosen based on rigorous performance metrics
- Explainable AI: SHAP-powered explanations for every prediction
- Feature Engineering: 18 carefully crafted features including location, condition, and derived metrics
- Real-time Predictions: Instant price estimates with comprehensive input validation
- Visual Explanations: Dynamic waterfall charts showing how each feature impacts the final price
- User-friendly Design: Clean, responsive interface with intuitive form inputs
- Model Performance Dashboard: Detailed metrics comparison with interactive charts
- SHAP Integration: Understand exactly why the model made each prediction
- Feature Impact Analysis: See which property characteristics drive price changes
- Outlier Detection: Robust IQR-based data cleaning for reliable predictions
- Comprehensive Metrics: RΒ², RMSE, MAE evaluation across all models
Try it now: House Price Predictor
| Component | Technology | Purpose |
|---|---|---|
| Backend | Flask, Python 3.8+ | Web framework & API |
| ML Models | XGBoost, Scikit-learn | Prediction algorithms |
| Explainability | SHAP | Model interpretability |
| Data Processing | Pandas, NumPy | Data manipulation |
| Visualization | Matplotlib, Seaborn | Charts & plots |
| Frontend | HTML5, CSS3, Bootstrap | User interface |
| Deployment | Render | Cloud hosting |
| Model | RΒ² Score | RMSE | MAE | Training Time | Status |
|---|---|---|---|---|---|
| XGBoost Regressor β | 0.8761 | 45,231 | 28,445 | 2.3s | β Selected |
| Random Forest | 0.8642 | 47,892 | 31,203 | 1.8s | Good |
| Gradient Boosting | 0.8534 | 49,567 | 32,891 | 3.1s | Good |
| Linear Regression | 0.7823 | 58,234 | 38,456 | 0.1s | Baseline |
XGBoost achieved 87.61% accuracy with the best overall performance across all metrics
house-price-predictor/
βββ π data_preprocessing.ipynb # Complete ML pipeline
βββ π§ predictor.py # Prediction engine with SHAP
βββ π app.py # Flask web application
βββ π models/
β βββ best_model.pkl # Trained XGBoost model
β βββ scaler.pkl # Feature scaler
βββ π templates/
β βββ index.html # Main prediction interface
β βββ metrics.html # Model performance dashboard
βββ π static/
β βββ images/ # Generated visualizations
βββ π model_metrics.csv # Performance comparison
βββ π README.md # This file
git clone https://github.com/yourusername/house-price-predictor.git
cd house-price-predictor
pip install -r requirements.txtpython app.pyNavigate to http://localhost:5000 π
Fill in the property details and get instant predictions with explanations!
pip install pandas numpy scikit-learn xgboost flask shap matplotlib seaborn joblib- Feature Engineering: Created house age, renovation status, and total area
- Outlier Removal: IQR method for robust data cleaning
- Scaling: StandardScaler for optimal model performance
- Cross-validation: Rigorous model comparison
- Hyperparameter Tuning: Optimized XGBoost parameters
- Feature Selection: 18 most predictive features
- Input Validation: Comprehensive error handling
- SHAP Analysis: Generate feature importance explanations
- Visualization: Dynamic waterfall charts
- Physical: Bedrooms, bathrooms, floors, living area
- Location: Latitude, longitude, airport distance
- Quality: Construction grade, house condition
- Amenities: Waterfront, views, nearby schools
- House Age: Current year - built year
- Renovation Status: Binary flag for recent updates
- Total Area: Living area + basement area
- Interactive RΒ² score comparison
- RMSE and MAE error metrics
- Performance visualization charts
- Feature contribution breakdown
- Visual explanation of predictions
- User-friendly impact descriptions
# Generate human-readable explanations
def get_impact_explanation(feature_name, impact_value, feature_value):
# Convert technical features to user-friendly explanations
return explanations[feature_name]['positive' if impact_value > 0 else 'negative']# Comprehensive model evaluation
def evaluate_model(model, name):
r2 = r2_score(y_test, preds)
rmse = np.sqrt(mean_squared_error(y_test, preds))
mae = mean_absolute_error(y_test, preds)
return {"Model": name, "R2 Score": r2, "RMSE": rmse, "MAE": mae}- Accurate Valuations: 85.42% prediction accuracy
- Instant Estimates: No waiting for manual appraisals
- Transparent Pricing: Clear explanations for clients
- Fair Market Value: Data-driven price insights
- Feature Impact: Understand what drives value
- Investment Decisions: Make informed choices
sample_input = {
'number of bedrooms': 4.0,
'number of bathrooms': 2.5,
'lot area': 5000.0,
'house_age': 25,
'was_renovated': 1,
'total_area': 2200.0
# ... more features
}
predicted_price, explanation, chart = predict_with_explain(sample_input)
# Output: βΉ45,67,890 with detailed explanations- Environment variable configuration
- Error handling and logging
- Scalable architecture
- Cloud deployment ready (Render/Heroku)
- Efficient model loading
- Caching mechanisms
- Optimized static assets
- Deep Learning Models: Neural network integration
- Real-time Data: Live market data feeds
- API Development: RESTful API for third-party integration
- Mobile App: React Native companion app
- Market Trends: Historical price analysis
- Investment ROI: Return on investment calculator
- Comparison Tool: Multiple property comparison
- Alerts System: Price change notifications
- End-to-End Pipeline: Complete ML workflow from data to deployment
- Explainable AI: Not just predictions, but understanding why
- Production Ready: Proper error handling, validation, and deployment
- Best Practices: Clean code, documentation, and testing
- User-Centric Design: Focus on interpretability and usability
- Multiple Models: Comprehensive comparison and selection
- Visual Storytelling: Charts that explain the "why" behind predictions
- Real-world Application: Solves actual industry problems
- Scalable Solution: Architecture supports growth
- Data-Driven Insights: Actionable intelligence for users
Built with passion for machine learning and real estate technology. This project demonstrates:
- Full-Stack Development: From data science to web deployment
- Machine Learning Expertise: Advanced algorithms and explainable AI
- Product Thinking: User-focused design and business value
- Technical Leadership: Clean architecture and best practices
- GitHub: GitHub Profile
- LinkedIn: LinkedIn Profile
- Email: rugvedchandekar@gmail.com
β Star this repository if you found it helpful!
Built with β€οΈ using Python, Flask, and XGBoost