Skip to content

About

Interactive D3.js & MathJax simulation of Random Forest classification, Bootstrap Aggregating (Bagging), random feature subspaces, and variance reduction for DSCI 35600 at Lindenwood University.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

🦁 Random Forest Ensemble — Interactive Masterclass & Visualizer

Lindenwood University — Interactive Data Science & Machine Learning Masterclass

Live Interactive Lab Course Author


📖 Overview

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/


📐 Mathematical Formulation

Given $B$ bootstrap samples ${\mathcal{D}_1^, \mathcal{D}_2^, \dots, \mathcal{D}B^*}$ drawn with replacement from training set $\mathcal{D}$, a Random Forest trains $B$ unpruned trees ${T_b}{b=1}^B$, selecting a random subset of $m \approx \sqrt{p}$ features at each candidate split.

  • 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$.

✨ Key Interactive Features

  • 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.

🎓 Pedagogical & Course Context

  • 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).

🚀 Running Locally

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

🔗 Explore the Complete Interactive Masterclass Suite

Module Topic Live Link
Linear Regression Ordinary Least Squares & Residual Minimization Launch
Logistic Regression Sigmoid Probabilities & Binary Cross-Entropy Launch
Regularization ($L_1 / L_2$) Lasso vs. Ridge Constraint Geometry Launch
K-Nearest Neighbors Instance-Based Learning & Distance Metrics Launch
Support Vector Machine Maximum-Margin Hyperplanes & Soft Margin $C$ Launch
RBF Kernel SVM Non-Linear Kernel Trick & $(\gamma, C)$ Tuning 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 & $F_1$-Score 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 & $K$-Fold Cross-Validation Launch
One-Hot Encoding Categorical Expansion & Dummy Variable Trap Launch

Developed with ❤️ for Data Science students by Sagar Kalauni · Portfolio

About

Interactive D3.js & MathJax simulation of Random Forest classification, Bootstrap Aggregating (Bagging), random feature subspaces, and variance reduction for DSCI 35600 at Lindenwood University.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages