def classifier_accuracy_report(self, prediction_vector, threshold=0.5):
""" Determine AUC and other metrics, write report.
prediction_vector: vector of booleans (or outcome
probabilities) of length n_subjects,
e.g. self.point_predictions, self.ensemble_probabilities()...
If this has dtype other than bool, prediction_vector > threshold
is used for the confusion matrix.
Returns: one string (multiple lines joined with \n, including
trailing newline) containing a formatted report.
"""
auc = roc_auc_score(self.model.data.y.astype(float), prediction_vector.astype(float))
if not (prediction_vector.dtype == np.bool):
prediction_vector = prediction_vector >= threshold
conf = confusion_matrix(self.model.data.y, prediction_vector)
lines = ['AUC: %.3f' % auc,
'Confusion matrix: \n\t%s' % str(conf).replace('\n','\n\t')]
return '\n'.join(lines) + '\n'
########################################
# BAYES-FACTOR-BASED METHODS
评论列表
文章目录