sklearn predict threshold

Solutions on MaxInterview for sklearn predict threshold by the best coders in the world

showing results for - "sklearn predict threshold"
Serena
22 Jun 2018
1from sklearn.tree import DecisionTreeClassifier
2clf = DecisionTreeClassifier(random_state = 2)
3clf.fit(X_train,y_train)
4# y_pred = clf.predict(X_test)  # default threshold is 0.5
5y_pred = (clf.predict_proba(X_test)[:,1] >= 0.3).astype(bool) # set threshold as 0.3