.. currentmodule:: mlpy Metrics ======= Compute metrics for assessing the performance of classification/regression models. Classification -------------- .. autofunction:: error .. autofunction:: accuracy Examples: >>> import mlpy >>> t = [3,2,3,3,3,1,1,1] >>> p = [3,2,1,3,3,2,1,1] >>> mlpy.error(t, p) 0.25 >>> mlpy.accuracy(t, p) 0.75 Binary Classification Only ^^^^^^^^^^^^^^^^^^^^^^^^^^ The Confusion Matrix: +--------------------------+-----------------------+-----------------------+ | Total Samples (ts) | Actual Positives (ap) | Actual Negatives (an) | +--------------------------+-----------------------+-----------------------+ | Predicted Positives (pp) | True Positives (tp) | False Positives (fp) | +--------------------------+-----------------------+-----------------------+ | Predicted Negatives (pn) | False Negatives (fn) | True Negatives (tn) | +--------------------------+-----------------------+-----------------------+ .. autofunction:: error_p .. autofunction:: error_n .. autofunction:: sensitivity .. autofunction:: specificity .. autofunction:: ppv .. autofunction:: npv .. autofunction:: mcc .. autofunction:: auc_wmw Examples: >>> import mlpy >>> t = [1, 1, 1,-1, 1,-1,-1,-1] >>> p = [1,-1, 1, 1, 1,-1, 1,-1] >>> mlpy.error_p(t, p) 0.25 >>> mlpy.error_n(t, p) 0.5 >>> mlpy.sensitivity(t, p) 0.75 >>> mlpy.specificity(t, p) 0.5 >>> mlpy.ppv(t, p) 0.59999999999999998 >>> mlpy.npv(t, p) 0.66666666666666663 >>> mlpy.mcc(t, p) 0.2581988897471611 >>> p = [2.3,-0.4, 1.6, 0.6, 3.2,-4.9, 1.3,-0.3] >>> mlpy.auc_wmw(t, p) 0.8125 >>> p = [2.3,0.4, 1.6, -0.6, 3.2,-4.9, -1.3,-0.3] >>> mlpy.auc_wmw(t, p) 1.0 Regression ---------- .. autofunction:: mse .. autofunction:: r2 .. autofunction:: r2_corr Example: >>> import mlpy >>> t = [2.4,0.4,1.2,-0.2,3.3,-4.9,-1.1,-0.1] >>> p = [2.3,0.4,1.6,-0.6,3.2,-4.9,-1.3,-0.3] >>> mlpy.mse(t, p) 0.052499999999999998