text_plain_output_1.png
from sklearn.ensemble import RandomForestClassifier

from sklearn.ensemble import RandomForestClassifier

from sklearn.metrics import accuracy_score

from sklearn.ensemble import RandomForestClassifier
rf_model = RandomForestClassifier()
rf_model.fit(X_train, y_train)
pred_s = rf_model.predict_proba(X_test)

y_pred = rf_model.predict(X_test)

from sklearn.ensemble import RandomForestClassifier
rf_model = RandomForestClassifier()
rf_model.fit(X_train, y_train)
pred_s = rf_model.predict_proba(X_test)

y_pred = rf_model.predict(X_test)

accuracy = accuracy_score(y_test, y_pred)
accuracy

threshold = 0.5
predicted = (pred_s[:, 1] >= threshold).astype('int')

threshold = 0.25
predicted = (pred_s[:, 1] >= threshold).astype('int')
accuracy = accuracy_score(y_test, predicted)
accuracy