random forest test accuracy code example
Example 1: how to improve accuracy of random forest classifier
from sklearn.model_selection import GridSearchCV
cv = GridSearchCV(rfc,parameters,cv=5)
cv.fit(train_features,train_label.values.ravel())
Example 2: how to improve accuracy of random forest classifier
# Find number of features for cumulative importance of 95%# Add 1 because Python is zero-indexedprint('Number of features for 95% importance:', np.where(cumulative_importances > 0.95)[0][0] + 1)Number of features for 95% importance: 6