learn module
- learn.auc(x, y)
Computes the area under curve of given ROC-values by applying the trapezodial rule.
Parameters
- xarray
x-values of the given funktion e.g. the FPR-values.
- yarray
y-values of the given funktion e.g. the TPR-values.
Returns
- float
The area under curve.
- learn.confusion_matrix(y_true, y_pred, labels=None)
Creates a confusion matrix from the binary classification and ground truth.
Parameters
- y_truearray
The ground truth labels.
- y_predarray
The predicted labels.
- labelstupel, optional
The desired labels. The default is None.
Returns
- matrixndarray
A 2x2 matrix containing the True Positive, True Negatife, False Positive and False Negative.
- learn.precision_recall_curve(y_true, probas_pred)
Computes the precision-recall-curve for given predicions. Much like the roc-funktion it takes two arrays of the same length. One with the predicting scores and one with the ground truth.
Parameters
- y_trueTYPE
The array with the ground truth in binary.
- probas_predTYPE
The array with the predicting scores.
Returns
- precisionsarray
An array with the precisions for each threshold.
- recallsarray
An array with the recall or sensitivity for each threshold.
- thresholdsarray
An array with the tresholds.
- learn.roc_curve(y_true, y_score)
Computes the ROC-values for given scores. It takes two arrays. One with the ground truth in binary an one with the scores. Both arrays must be of the same length, otherwise an error occurs. Example:
# generating dummy ground truth a1 = np.zeros(10, dtype=int) a2 = np.ones(10, dtype=int) dummy_ground_truth = np.concatenate((a1, a2)) np.random.shuffle(dummy_ground_truth) dummy_scores = np.random.rand(20) fpr_dummy, tpr_dummy, thresh_dummy = roc_curve(dummy_ground_truth, dummy_scores) print('FPR:', fpr_dummy) print('TPR:', tpr_dummy) print('thresholds:' thresh_dummy)
Parameters
- y_truearray
The array with the graund truth values e.g. the annotation.
- y_scorearray
The array with the scoring values.
Returns
- fprarray
The false positive rates for every threshold.
- tprarray
The true positive rate for every threshold.
- thresholdsarray
The thresholds.