Random Forest
noun
say it: “RAN-dum FOR-ist” /ˈrændəm ˈfɔrəst/
A machine learning model made of many decision trees, each trained on a random part of the data, whose answers are combined.
What is a random forest?
A random forest is many decision trees working together. Each tree learns from its own random bootstrap sample of the rows and considers a random few features at each question, so the trees make different mistakes; the forest takes their majority vote, or their average for a number, which usually beats any one tree.
from sklearn.ensemble import RandomForestClassifier
fruit = [[120, 3], [125, 4], [130, 3], [180, 8], [185, 9], [190, 8]] # grams, sweetness
names = ["lemon"] * 3 + ["orange"] * 3
forest = RandomForestClassifier(n_estimators=100, random_state=0).fit(fruit, names)
print(len(forest.estimators_), forest.predict([[182, 8]])) # 100 ['orange']
In a sentence
- “The random forest of 300 trees beat the single tree by 4 points.”
- “A random forest is harder to read than one tree, so she explained it with permutation importance.”
Level: Journeyman · More AI Basics terms at this level
Updated