August 2019
Intermediate to advanced
342 pages
9h 35m
English
The choice falls on one of the most used among the ensemble algorithms, that is, the random forest algorithm.
This type of algorithm is used by the RandomForestClassifier class of scikit-learn to create a set of decision trees from a subset extracted at random from a training set.
The algorithm represents an example of a learning ensemble that uses the bagging technique and is, therefore, particularly suitable for reducing the overfitting of the model.
Let's look at an example of RandomForestClassifier and its accuracy score:
from sklearn.ensemble import RandomForestClassifierfrom sklearn import metricsrfmodel = RandomForestClassifier()rfmodel.fit(xtrain,ytrain)ypredrf = rfmodel.predict(xtest)print('Accuracy ...Read now
Unlock full access