text_plain_output_1.png image_output_1.png
from imblearn.over_sampling import SMOTE

from sklearn.ensemble import RandomForestClassifier

from sklearn.metrics import accuracy_score

smt = SMOTE(random_state=0)
xtrain_res, ytrain_res = smt.fit_resample(xtrain, ytrain)

rf = RandomForestClassifier(max_depth=3, random_state=0)
rf.fit(xtrain_res, ytrain_res)

ypred = rf.predict(xtest)
print('Cccuracy:', accuracy_score(ytest, ypred))