python - Is it possible that Precision-Recall curve or a ROC curve is a horizontal line? -


i working on binary classification task on imbalanced data.

since accuracy not meaningful in case. use scikit-learn compute precision-recall curve , roc curve in order evaluate model performance.

but found both of curves horizontal line when use random forest lot of estimators, happens when use sgd classifier fit it.

the roc chart following:

enter image description here

and precision-recall chart:

enter image description here

since random forest behaves randomly, don't horizontal line in every run, regular roc , pr curve. horizontal line more common.

is normal? or made mistakes in code?

here snippet of code:

classifier.fit(x_train, y_train) try:     scores = classifier.decision_function(x_test) except:     scores = classifier.predict_proba(x_test)[:,1]  precision, recall, _ = precision_recall_curve(y_test, scores, pos_label=1) average_precision = average_precision_score(y_test, scores)  plt.plot(recall, precision, label='area = %0.2f' % average_precision, color="green") plt.xlim([0.0, 1.0]) plt.ylim([0.0, 1.05]) plt.xlabel('recall') plt.ylabel('precision') plt.title('precision recall curve') plt.legend(loc="lower right") plt.show() 

yes, can. if separate data 2 piles, go vertically 0 1 true-positive-rate without false positives (the vertical line) threshold passes on pile of true positives, 0 1 false-positive-rate threshold passes on pile of true negatives.

if can same roc curve test set, golden. if can same roc curve evaluated on 5 different k-fold cross validation test sets, platinum.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -