July 2019
Beginner to intermediate
298 pages
7h 20m
English
The Random Forests classification class is implemented in RandomForestClassifier, under the sklearn.ensemble package. It has a number of parameters, such as the ensemble's size, the maximum tree depth, the number of samples required to make or split a node, and many more.
In this example, we will try to classify the hand-written digits dataset, using the Random Forest classification ensemble. As usual, we load the required classes and data and set the seed for our random number generator:
# --- SECTION 1 ---# Libraries and data loadingfrom sklearn.datasets import load_digitsfrom sklearn.ensemble import RandomForestClassifierfrom sklearn import metricsimport numpy as npdigits = load_digits()train_size = 1500 ...
Read now
Unlock full access