| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A comprehensive implementation of Random Forests from scratch, including theoretical foundations, custom implementations, and extensive experiments on real-world datasets.
This project addresses Question 2 from the Machine Learning Lab Mid-term examination, which requires:
✅ Custom Implementation: Decision Tree and Random Forest built from scratch with full mathematical formulations
✅ Theoretical Foundation: Detailed explanations based on Leo Breiman's 2001 paper
✅ Dual Experiments: Heart Disease UCI (tabular) and Intel Image Classification (image)
✅ Comprehensive Analysis: Accuracy plots, confusion matrices, feature importance
✅ Production-Ready Code: Clean, documented, and reproducible
Understand and explain the two key ingredients of Random Forests:
Conduct experiments to explore:
Provide insights on:
Build-Random-Forests-From-scratch/
│
├── README.md # This file
├── REPORT.md # Comprehensive report (Part C)
├── THEORY.md # Theoretical foundation (Part A)
├── BREIMAN_SUMMARY.md # Summary of Breiman's 2001 paper
│
├── requirements.txt # Python dependencies
├── config.py # Configuration and parameters
│
├── decision_tree_scratch.py # Decision Tree from scratch
├── random_forest_scratch.py # Random Forest from scratch
│
├── utils.py # Data loading and preprocessing
├── visualization.py # Plotting utilities
│
├── experiments_heart_disease.py # Experiments on Heart Disease dataset
├── experiments_image_classification.py # Experiments on Image dataset
├── test_custom_implementation.py # Testing script
│
├── JSON_RESULTS_STRUCTURE.md # JSON results documentation
│
├── data/ # Datasets (downloaded automatically)
│ ├── heart_disease/
│ └── intel_images/
│
└── outputs/ # Results and plots
├── plots/ # Generated visualizations
└── results/ # Experiment results
├── *.pkl # Pickle format (Python)
└── *.json # JSON format (human-readable)
git clone https://github.com/codewithdark-git/Build-Random-Forests-From-scratch.git
cd Build-Random-Forests-From-scratchpip install -r requirements.txtStrength of individual trees
Low correlation between trees
Mathematical formulations
Intuitive explanations
BREIMAN_SUMMARY.md: Summary of Breiman's 2001 paper
REPORT.md: Comprehensive report (Part C)
All Python files include:
Features:
Mathematical Foundations:
Features:
Mathematical Foundations:
Edit config.py to customize:
# Random seed for reproducibility
RANDOM_STATE = 42
# Experiment parameters
N_ESTIMATORS_RANGE = [1, 10, 50, 100, 300]
TEST_SIZE = 0.2
# Random Forest parameters
RF_MAX_FEATURES = 'sqrt'
RF_BOOTSTRAP = True
RF_OOB_SCORE = True
# Image processing
IMAGE_SIZE = (64, 64)
MAX_IMAGES_PER_CLASS = 1000All plots are automatically generated and saved to outputs/plots/:
See requirements.txt for specific versions.
Contributions are welcome! Please:
This project is licensed under the MIT License - see LICENSE file for details.
Your Name
Note: This project is created for educational purposes as part of a Machine Learning course assignment (Question 2 - Random Forests).
Last Updated: December 2025
| Back | FazBrowse Home | New Git URL |