StatQuest: Random Forests Part 2: Missing data and clustering
Overview
Josh Starmer's StatQuest on Random Forests Part 2 details two methods for handling missing data: imputation during model training and classification of new samples. For training data, missing values are initially guessed and iteratively refined using proximity matrices derived from running data through random forest trees. For new samples, two versions are created (one for each potential outcome of the missing feature) and run through the forest to determine which best aligns with the model's predictions.
Key takeaways
- Random forests handle missing data in training sets by iteratively refining initial guesses using proximity measures derived from tree leaf node assignments.
- Proximity matrices, calculated by tracking co-occurrence in leaf nodes across trees, can be transformed into distance matrices for visualization (heatmaps, MDS plots).
- For classifying new samples with missing features, two versions of the sample are created (one for each potential value of the missing feature) and run through the forest to determine the most likely classification.
- The iterative refinement of missing values in training data continues until the imputed values stabilize across iterations.
- The proximity of samples in a random forest is defined by how often they end up in the same leaf node across all trees in the forest.
Chapters
- Missing data in the original training set requires an initial guess for categorical (most common value) and numeric (median value) features.
- Proximity matrices are built by running data down random forest trees, counting how often samples land in the same leaf node.
- Proximity values are normalized by the total number of trees and used to refine guesses for missing categorical (weighted average proximity) and numeric (weighted average) values.
- This imputation process is repeated iteratively until missing values converge.
Transcript excerpt
0:00 Random Forest Part Two. Hip hip. Hooray. It's true. Stat Quest. Hello, I'm Josh Starmer and welcome to Stat Quest. Today we're doing Random Forest part two and we're going to focus on missing data in sample clustering. To be honest, the sample clustering aspect of random forest is my favorite part. So, I'm really excited we're going to cover it. Here's our data set. We've got data for four separate patients. However, for patient number four, we've got some missing data. Random forests consider two types of missing data. One, missing data in the original data set used to create the random forest. And two, missing data in a new sample that we want to categorize.
0:49 We'll start with this one. So, we want to create a random forest from this data. However, we don't know if this patient has blocked arteries or their weight. The general idea for dealing with missing data in this context is to make an initial guess that could be bad and then gradually refine the guess until it is hopefully a good guess. Because this person did not have heart disease, the initial and possibly bad guess for the blocked arteries value is just the most common value for blocked arteries found in the other samples that do not have heart disease. Among the people that do not have heart disease, no is the most common value for blocked arteries. It occurs in two out
1:39 of two samples. So no is our initial guess. Since weight is numeric, our initial guess will be the median value of the patients that did not have heart disease. In this case, the median value is 167.5. Here's our new data set with the filledin missing values. Now we want to refine these guesses. We do this by first determining which
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, StatQuest with Josh Starmer.