Eval

The classeval library contains various functions to plot the results. The main function to plot is the function classeval.classeval.plot(). This function automatically determines whether the trained model is based on a two-class or multi-class approach. Plotting results is possible by simply using the classeval.classeval.plot() functionality.

Lets first train a simple model:

# Load data
X, y = clf.load_example('breast')
X_train, X_test, y_train, y_true = train_test_split(X, y, test_size=0.2)

# Fit model
model = gb.fit(X_train, y_train)
y_proba = model.predict_proba(X_test)[:,1]
y_pred = model.predict(X_test)

Evaluate the models performance and use the output for making the plots.

# Import library
import classeval as clf

# Evaluate model
out = clf.eval(y_true, y_proba, pos_label='malignant')

# Make plot
ax = clf.plot(out)

Two-class

_images/example1_fig1.png

ROC-AUC

Plotting the ROC is initially desiged for two-class models. However, with some adjustments it is also possible to plot the ROC for a multi-class model under the assumption that is OvR or OvO schemes. See methods section for more details. With the function classeval.ROC.eval() the ROC and AUC can be examined and plotted for both the two-class as well as multi-class models.

# Compute ROC
outRoc = clf.ROC.eval(y_true, y_proba, pos_label='malignant')

# Make plot
ax = clf.ROC.plot(outRoc)

Two-class

_images/ROC_twoclass.png

Multi-class

_images/multiclass_fig1_1.png

CAP

# Compute CAP
outCAP = clf.CAP(out['y_true'], out['y_proba'], showfig=True)
_images/CAP_fig.png

AP

# Compute AP
outAP = clf.AP(out['y_true'], out['y_proba'], showfig=True)
_images/AP_fig.png

Confusion matrix

A confusion matrix is a table to describe the performance of a classification model. With the function classeval.confmatrix.eval() the confusion matrix can be examined and plotted for both the two-class as well as multi-class model.

# Compute confmatrix
outCONF = clf.confmatrix.eval(y_true, y_pred)

# Make plot
ax = clf.confmatrix.plot(outCONF)

Two-class

_images/Figure_2.png

Multi-class

_images/multiclass_fig1_4.png

Probability Plot

The probability plot depicts the probabilities of the samples being classified. This function is desiged for only two-class models and callable via: classeval.classeval.TPFP()

# Compute TPFP
out = clf.TPFP(out['y_true'], out['y_proba'], showfig=True)
_images/multiclass_threshold_05.png