Click or drag to resize
sqx

ConfusionMatrixConfusionMatrixTable Method

Function [table] ConfusionMatrixTable([ContingencyData] Summary)
(Confusion Matrix)

Namespace:  sqx
Assembly:  SQX (in SQX.dll) Version: 1.0.2.6 (1.0.2.6)
Syntax
C#
public static IEnumerator ConfusionMatrixTable(
	ContingencyData Summary
)

Parameters

Summary
Type: sqxContingencyData
[ContingencyData]

Return Value

Type: IEnumerator
[table]
Remarks
Confusion matrix table.

Attributes

IsDeterministic = true, IsPrecise = true, DataAccess = DataAccessKind.None, SystemDataAccess = SystemDataAccessKind.None, TableDefinition = "TP bigint,FP bigint,FN bigint,TN bigint,N bigint,POS bigint,NEG bigint,AUC float,CSI float,PPV float,TPR float,FPR float,MCC float,ACC float,BA float,ERRR float,YoudensJ float,F1Score float,Markedness float,Informedness float,BIAS float,Prevalence float,NPV float,TNR float,FNR float,FDR float,[FOR] float,PLR float,NLR float,DOR float,[DOR_SE] float"
Examples
SQL
;WITH sample_data AS (SELECT g.Value MyGroup
, sqx.BernoulliD_PPF(a.Value, 0.6) Observed
, sqx.BernoulliD_PPF(b.Value, 0.7) Predicted
FROM sqx.NTable(1,3) g
CROSS APPLY sqx.UTable(1000,g.Value) a
CROSS APPLY sqx.UTable(1000,g.Value + 10) b
WHERE a.ID = b.ID)
SELECT ct.MyGroup, cmt.*
FROM (SELECT MyGroup, sqx.CROSSTAB(Observed, Predicted) CT 
    FROM sample_data
    GROUP BY MyGroup
) ct
CROSS APPLY sqx.ConfusionMatrixTable(ct.CT) cmt
/*
MyGroup     TP         FP         FN         TN         N          POS        NEG        NL         AUC                    CSI                    PPV                    TPR                    FPR                    MCC                    ACC                    BA                     ERRR                   YoudensJ               F1Score                Markedness             Informedness           BIAS                   Prevalence             NPV                    TNR                    FNR                    FDR                    FOR                    PLR                    NLR                    DOR                    DOR_SE
----------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- -------------------
1           429        269        172        130        1000       601        399        0          0.51981242624031       0.493103448275862      0.614613180515759      0.713810316139767      0.674185463659148      0.042262984200595      0.559                  0.51981242624031       0.441                  0.0396248524806192     0.660508083140878      0.0450767566746997     0.0396248524806193     0.698                  0.601                  0.43046357615894       0.325814536340852      0.286189683860233      0.385386819484241      0.56953642384106       1.05877440944151       0.878382183540254      1.2053687213625        1.15008775492737
2           433        258        182        127        1000       615        385        0          0.516967585260268      0.495990836197022      0.626628075253256      0.704065040650407      0.67012987012987       0.0357354861816254     0.56                   0.516967585260268      0.44                   0.0339351705205364     0.663093415007657      0.0376313114992108     0.0339351705205364     0.691                  0.615                  0.411003236245955      0.32987012987013       0.295934959349594      0.373371924746744      0.588996763754045      1.05063969244344       0.897125664170028      1.17111764204787       1.15008456146805
3           432        300        154        114        1000       586        414        0          0.506281842014147      0.487584650112867      0.59016393442623       0.737201365187713      0.72463768115942       0.0139715003689119     0.546                  0.506281842014147      0.454                  0.012563684028293      0.655538694992413      0.0155370687545877     0.012563684028293      0.732                  0.586                  0.425373134328358      0.27536231884058       0.262798634812287      0.409836065573771      0.574626865671642      1.01733788395904       0.954373989581462      1.06597402597403       1.15559492526881*/
SQL
;WITH sample_data AS (SELECT sqx.BernoulliD_PPF(a.Value, 0.6) Observed
, sqx.BernoulliD_PPF(b.Value, 0.6) Predicted
FROM sqx.UTable(1000,1) a, sqx.UTable(1000,3) b
WHERE a.ID = b.ID)
SELECT cmt.*
FROM sqx.ConfusionMatrixTable((SELECT sqx.CROSSTAB(Observed, Predicted) FROM sample_data)) cmt
/*
TP               FP               FN               TN               N                POS              NEG              NL               AUC                  CSI                  PPV                  TPR                  FPR                  MCC                    ACC                BA                   ERRR               YoudensJ               F1Score                Markedness             Informedness           BIAS               Prevalence         NPV                 TNR                 FNR                FDR                FOR                PLR                NLR                DOR                DOR_SE
---------------- ---------------- ---------------- ---------------- ---------------- ---------------- ---------------- ---------------- -------------------- -------------------- -------------------- -------------------- -------------------- ---------------------- ------------------ -------------------- ------------------ ---------------------- ---------------------- ---------------------- ---------------------- ------------------ ------------------ ------------------- ------------------- ------------------ ------------------ ------------------ ------------------ ------------------ ------------------ -----------------
354              232              247              167              1000             601              399              0                0.503782334371703    0.424969987995198    0.604095563139932    0.589018302828619    0.581453634085213    0.00752081005502539    0.521              0.503782334371703    0.479              0.00756466874340594    0.596461668070767      0.00747720565200893    0.00756466874340589    0.586              0.601              0.403381642512077   0.418546365914787   0.410981697171381  0.395904436860068  0.596618357487923  1.01300992598543   0.981926330367551  1.03165573083903   1.14001481174305*/
See Also

Reference