diff --git a/GPy/util/classification.py b/GPy/util/classification.py new file mode 100644 index 00000000..07e725d1 --- /dev/null +++ b/GPy/util/classification.py @@ -0,0 +1,30 @@ +import numpy as np + +def conf_matrix(p,labels,names=['1','0'],threshold=.5,show=True): + """ + Returns true and false positives in a binary classification problem + - Column names: true class of the examples + - Row names: classification assigned by the model + + p: probabilities estimated for observation of belonging to class '1' + labels: observations' class + names: classes' names + threshold: probability value at which the model allocate an element to each class + show: whether the matrix should be shown or not + """ + p = p.flatten() + labels = labels.flatten() + N = p.size + C = np.ones(N) + C[p