March 2019
Beginner to intermediate
464 pages
10h 57m
English
Training a random forest model using scikit-learn is simple. Take a look at the following code:
rf_model = RandomForestClassifier( n_estimators=200, max_depth=5)rf_model.fit(X=x_train, y=y_train)
Using the RandomforestClasifier class in the scikit-learn package's ensemble module, you first need to create a RandomforestClasifier object with the hyperparameters. For illustration purposes, we are instructing the model to build 200 trees, where each tree can only grow up to the depth of 5. Then, you can train this model with the fit function, which takes two parameters, X and y, where X is for the training samples and y is for the training labels or target values.
When you run this code, you will see an output that ...
Read now
Unlock full access