Chapter XIII
Random Forest
โฆ โฆ โฆ
The Source
ยง I Demonstration
if __name__ == "__main__":
# temperature (celsius), humidity (%)
X = [
[15, 40],
[20, 35],
[32, 85],
[35, 90],
]
# play outside?
y = [1, 1, 0, 0]
# p = len(X[0]) # number of features
# m = max(1, int(sqrt(p)))
m = 2 # I'll use 2 for this example because I only have 2 features
forest = Bagging(k=4, n=5, m=m)
forest.fit(X, y)
yy = forest.predict([[25, 30], [35, 55], [30, 60]])
print(yy) # [1, 0, 0]