Performance curves

class Orange.evaluation.performance_curves.Curves(ytrue, probs)[source]

Computation of performance curves (ca, f1, precision, recall and the rest of the zoo) from test results.

The class works with binary classes. Attribute probs contains ordered probabilities and all curves represent performance statistics if an instance is classified as positive if it equals or exceeds the threshold in probs, that is, sensitivity[i] is the sensitivity of the classifier that classifies an instances as positive if the probability of being positive is at least probs[i].

Class can be constructed by giving probs and ytrue, or from test results (see Curves.from_results). The latter removes instances with missing class values or predicted probabilities.

The class treats all results as obtained from a single run instead of computing separate curves and fancy averaging.

Parameters:
  • probs (np.ndarray) – vector of predicted probabilities
  • ytrue (np.ndarray) – corresponding true classes
probs

ordered vector of predicted probabilities

Type:np.ndarray
ytrue

corresponding true classes

Type:np.ndarray
tot

total number of data instances

Type:int
p

number of real positive instances

Type:int
n

number of real negative instances

Type:int
tp

number of true positives (property computed from tn)

Type:np.ndarray
fp

number of false positives (property computed from tn)

Type:np.ndarray
tn

number of true negatives (property computed from tn)

Type:np.ndarray
fn

number of false negatives (precomputed, not a property)

Type:np.ndarray
classmethod from_results(results, target_class=None, model_index=None)[source]

Construct an instance of Curves from test results.

Parameters:
  • results (Orange.evaluation.testing.Results) – test results
  • target_class (int) – target class index; if the class is binary, this defaults to 1, otherwise it must be given
  • model_index (int) – model index; if there is only one model, this argument can be omitted
Returns:

curves (Curves)

ca()[source]

Classification accuracy curve

f1()[source]

F1 curve

sensitivity()[source]

Sensitivity curve

specificity()[source]

Specificity curve

precision()[source]

Precision curve

The last element represents precision at threshold 1. Unless such a probability appears in the data, the precision at this point is undefined. To avoid this, we copy the previous value to the last.

recall()[source]

Recall curve

ppv()[source]

PPV curve; see the comment at precision

npv()[source]

NPV curve

The first value is undefined (no negative instances). To avoid this, we copy the second value into the first.

fpr()[source]

FPR curve

tpr()[source]

TPR curve