An interactive visual exploration of Random Forests, demonstrating how aggregating an ensemble of decorrelated, high-variance decision trees trained via Bootstrap Aggregating (Bagging) and random feature subspaces yields a smooth, low-variance decision boundary.
🔗 Launch the Live Interactive Application: https://sagarkalauni.github.io/random-forest/
Given
-
Ensemble Classification Prediction (Majority Vote):
$$\hat{y}_{\text{RF}}(\mathbf{x}) = \text{mode} \left{ T_1(\mathbf{x}), T_2(\mathbf{x}), \dots, T_B(\mathbf{x}) \right}$$ -
Variance of Identically Distributed Correlated Trees: If each tree has variance
$\sigma^2$ and pairwise correlation$\rho$ , the variance of the ensemble average is:$$\text{Var}\left(\frac{1}{B}\sum_{b=1}^{B} T_b(\mathbf{x})\right) = \rho \sigma^2 + \frac{1 - \rho}{B} \sigma^2$$ Random feature subsampling reduces$\rho$ , driving down total generalization error as$B \to \infty$ .
- Individual Trees vs. Forest Consensus: Inspect the jagged decision boundaries of individual base trees alongside the smoothed ensemble boundary.
- Bootstrap Resampling Visualization: See how out-of-bag (OOB) and in-bag samples vary across trees.
-
Ensemble Size (
$B$ ) Scaling: Dynamically add trees to observe variance reduction and test-error stabilization. - Probability Margin Heatmap: Visualize consensus confidence across the 2D feature plane.
- Institution: Lindenwood University (College of Science, Technology, and Health)
- Course Curriculum: DSCI 35600 — Machine Learning
- Instructor & Author: Sagar Kalauni, M.S. (Full-Time Faculty in Data Science)
- Tech Stack: HTML5, Tailwind CSS, D3.js (Dynamic Data Visualization), MathJax (LaTeX Mathematical Rendering), Vanilla ES6+ JavaScript (Zero-Dependency Client-Side Execution).
Because this visualizer is engineered as a self-contained, zero-build client-side application, you can run it immediately in any modern browser:
# Clone the repository
git clone https://github.com/SagarKalauni/random-forest.git
# Navigate into the project directory
cd random-forest
# Open index.html directly in your browser or serve locally:
python -m http.server 8000| Module | Topic | Live Link |
|---|---|---|
| Linear Regression | Ordinary Least Squares & Residual Minimization | Launch |
| Logistic Regression | Sigmoid Probabilities & Binary Cross-Entropy | Launch |
| Regularization ( |
Lasso vs. Ridge Constraint Geometry | Launch |
| K-Nearest Neighbors | Instance-Based Learning & Distance Metrics | Launch |
| Support Vector Machine | Maximum-Margin Hyperplanes & Soft Margin |
Launch |
| RBF Kernel SVM | Non-Linear Kernel Trick & |
Launch |
| Decision Tree (CART) | Recursive Splitting, Gini & Entropy | Launch |
| Random Forest | Bagging & Ensemble Variance Reduction | Launch |
| Voting Classifier | Hard Majority vs. Soft Probability Voting | Launch |
| K-Means Clustering | Lloyd's Algorithm, Voronoi & Elbow WCSS | Launch |
| Confusion Matrix | Precision, Recall, Specificity & |
Launch |
| Confidence vs. Prediction Intervals | Mean Response vs. Individual Uncertainty | Launch |
| Bootstrapping | Non-Parametric Resampling with Replacement | Launch |
| Q-Q Plot | Gaussian Normality & Tail Diagnostics | Launch |
| Train-Test Split & CV | Holdout Partitioning & |
Launch |
| One-Hot Encoding | Categorical Expansion & Dummy Variable Trap | Launch |