Course: Data Science & Machine Learning Date: July 29, 2026 Author: Boateng Prince Agyenim
This project demonstrates professional-grade supervised machine learning workflows for:
- Regression: Housing price prediction
- Classification: Customer churn prediction
The implementation follows industry best practices including proper data preprocessing, pipeline usage, cross-validation, and model deployment.
Project/
β
βββ data/ # Raw datasets
β βββ housing.csv # Housing price data (500 samples)
β βββ customers.csv # Customer churn data (800 samples)
β
βββ notebooks/ # Jupyter notebooks for analysis
β βββ 01_Data_Exploration.ipynb
β βββ 02_Regression_Housing_Prices.ipynb
β βββ 03_Classification_Customer_Churn.ipynb
β
βββ src/ # Python scripts
β βββ supervised_ml_complete.py # Main workflow script
β βββ interactive_exploration.py # Data exploration
β βββ use_saved_models.py # Model deployment demo
β βββ advanced_tuning.py # Hyperparameter optimization
β
βββ models/ # Trained models
β βββ housing_price_model.joblib
β βββ housing_scaler.joblib
β βββ churn_prediction_model.joblib
β
βββ visualizations/ # Generated plots
β βββ housing_exploration.png
β βββ churn_model_results.png
β βββ model_comparison_regression.png
β βββ model_comparison_classification.png
β βββ confusion_matrix.png
β βββ roc_curves.png
β
βββ docs/ # Documentation
β βββ README.md # This file
β βββ QUICK_START.md # Quick start guide
β βββ ASSIGNMENT_SUMMARY.md # Detailed results report
β
βββ requirements.txt # Python dependencies
pip install -r requirements.txtjupyter notebookNavigate to notebooks/ and run in order:
01_Data_Exploration.ipynb- Understand the data02_Regression_Housing_Prices.ipynb- Housing price prediction03_Classification_Customer_Churn.ipynb- Churn prediction
# Complete workflow (both regression and classification)
python src/supervised_ml_complete.py
# Interactive data exploration
python src/interactive_exploration.py
# Test saved models
python src/use_saved_models.py
# Advanced hyperparameter tuning
python src/advanced_tuning.py| Model | RΒ² Score | RMSE | MAE |
|---|---|---|---|
| Linear Regression | 0.9281 | $19,114 | $15,675 |
| Ridge (Best) | 0.9303 | $18,819 | $15,508 |
| Lasso | 0.9295 | $18,925 | $15,562 |
| ElasticNet | 0.9294 | $18,930 | $15,568 |
Best Model: Ridge Regression
Performance: Excellent (93% variance explained)
Cross-Validation: Mean RΒ² = 0.9128 (Β±0.0067)
| Model | Accuracy | Precision | Recall | F1-Score | ROC-AUC |
|---|---|---|---|---|---|
| Logistic Regression (Best) | 0.694 | 0.500 | 0.286 | 0.364 | 0.738 |
| Random Forest | 0.681 | 0.464 | 0.265 | 0.338 | 0.687 |
| Gradient Boosting | 0.675 | 0.452 | 0.265 | 0.333 | 0.702 |
| Decision Tree | 0.656 | 0.412 | 0.286 | 0.337 | 0.647 |
| KNN | 0.644 | 0.382 | 0.265 | 0.313 | 0.618 |
Best Model: Logistic Regression
Performance: Moderate (typical for churn prediction)
Cross-Validation: Mean F1 = 0.4312 (Β±0.0428)
β
Complete preprocessing pipelines
β
Proper train-test splitting (no data leakage)
β
Stratified splitting for imbalanced classes
β
Feature scaling and encoding
β
Cross-validation for robust evaluation
β
Hyperparameter tuning examples
β
Model persistence (saving/loading)
β
Production-ready code
β
Pipelines prevent data leakage
β
Appropriate metrics for each task
β
Cross-validation for reliability
β
Comprehensive visualizations
β
Well-documented code
β
Modular, reusable structure
- Jupyter Notebooks - Interactive, step-by-step guides in
notebooks/
- Python 3.12
- pandas - Data manipulation
- numpy - Numerical operations
- scikit-learn - Machine learning models and tools
- matplotlib & seaborn - Visualizations
- joblib - Model persistence
- jupyter - Interactive notebooks
All visualizations are saved in the visualizations/ folder:
- housing_exploration.png - Price distribution and correlations
- churn_model_results.png - Model comparison for churn
- model_comparison_regression.png - Regression model metrics
- model_comparison_classification.png - Classification model metrics
- confusion_matrix.png - Churn prediction confusion matrix
- roc_curves.png - ROC curves for all classification models
This project demonstrates:
- Complete ML Workflow - From data loading to deployment
- Regression & Classification - Both major supervised learning tasks
- Data Preprocessing - Missing values, encoding, scaling
- Model Selection - Training and comparing multiple algorithms
- Evaluation - Appropriate metrics for different problems
- Best Practices - Pipelines, CV, avoiding data leakage
- Production Deployment - Model saving and loading
- Strong Performance: 93% RΒ² indicates excellent predictions
- Key Predictor: Square footage is most important (r=0.908)
- Neighborhood Effect: Up to $56K price difference between areas
- Model Choice: Ridge regularization improves generalization
- Moderate Performance: 69% accuracy, 74% AUC (typical for churn)
- Class Imbalance: Only 31% churn rate affects recall
- Business Value: Identifies some high-risk customers for retention
- Contract Insight: Month-to-month contracts have 42% churn vs 5% for two-year
To adapt this project for your own data:
- Replace CSV files in
data/folder - Update column names in notebooks/scripts
- Adjust preprocessing steps as needed
- Re-run the workflow
For submission, this project includes:
- β 3 Jupyter Notebooks - Interactive analysis
- β 4 Python Scripts - Automated workflows
- β 3 Trained Models - Ready for deployment
- β 6 Visualizations - Results and insights
- β Complete Documentation - README, guides, summary
All random states are fixed (random_state=42) for reproducible results:
- Train-test splits
- Model training
- Cross-validation folds
- Add more features (school districts, crime rates, amenities)
- Try polynomial features for non-linear relationships
- Ensemble methods (stacking, blending)
- Collect more features (usage patterns, complaints, satisfaction scores)
- Address class imbalance (SMOTE, class weights)
- Try advanced models (XGBoost, Neural Networks)
- Cost-sensitive learning (weight false negatives higher)
For questions or issues:
- Check the documentation in
docs/ - Review the Jupyter notebooks for examples
- Examine code comments in
src/scripts
- Data exploration and visualization
- Proper preprocessing (missing values, encoding, scaling)
- Train-test splitting with no data leakage
- Multiple regression models trained and evaluated
- Multiple classification models trained and evaluated
- Appropriate metrics used for each task
- Cross-validation performed
- Models saved for deployment
- Comprehensive visualizations
- Well-documented code
- Professional project structure
- Reproducible results
Project Status: Complete and Ready for Submission
Execution Time: ~1 minute for complete workflow
Lines of Code: 800+ lines across all scripts
Models Trained: 9 algorithms (4 regression + 5 classification)
Documentation: 4 comprehensive documents
This project follows best practices from the course "Supervised ML with Python" and scikit-learn documentation.