text_html_output_1.png
from sklearn.ensemble import RandomForestClassifier

from sklearn.metrics import accuracy_score

best_score = -1
best_estimators = 0
for i in range(10, 250):
    model = RandomForestClassifier(n_estimators=i, random_state=0)
    model.fit(train_x, train_y)
    pred = model.predict(test_x)
    score = accuracy_score(pred, test_y)
    if score > best_score:
        best_score = score
        best_estimators = i
print('The best number of estiamtors was %d with accuracy score %f' % (best_estimators, best_score * 100))