| 1 |
#ifndef _Confusion_h_ |
| 2 |
#define _Confusion_h_ |
| 3 |
/* Confusion.h |
| 4 |
* |
| 5 |
* Copyright (C) 1993-2019 David Weenink |
| 6 |
* |
| 7 |
* This code is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 2 of the License, or (at |
| 10 |
* your option) any later version. |
| 11 |
* |
| 12 |
* This code is distributed in the hope that it will be useful, but |
| 13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
* General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "TableOfReal.h" |
| 22 |
#include "Categories.h" |
| 23 |
#include "Graphics.h" |
| 24 |
#include "Matrix.h" |
| 25 |
|
| 26 |
Thing_define (Confusion, TableOfReal) { |
| 27 |
void v1_info () |
| 28 |
override; |
| 29 |
}; |
| 30 |
|
| 31 |
/* |
| 32 |
A Confusion matrix has both row and column labels. Row labels represent the stimulus names, |
| 33 |
column labels represent the responses. |
| 34 |
*/ |
| 35 |
|
| 36 |
autoConfusion Confusion_create (integer numberOfStimuli, integer numberOfResponses); |
| 37 |
|
| 38 |
autoConfusion Confusion_createSimple (conststring32 labels); |
| 39 |
|
| 40 |
autoConfusion Confusion_createFromStringses (Strings stimulusLabels, Strings responseLabels); |
| 41 |
|
| 42 |
autoConfusion Categories_to_Confusion (Categories me, Categories thee); |
| 43 |
|
| 44 |
void Confusion_increase (Confusion me, conststring32 stimulus, conststring32 response); |
| 45 |
/* Increase the confusion count by one: data ['stim'] ['resp'] += 1; */ |
| 46 |
|
| 47 |
double Confusion_getValue (Confusion me, conststring32 stimulus, conststring32 response); |
| 48 |
/* data ['stim'] ['resp'] ; */ |
| 49 |
|
| 50 |
void Confusion_getEntropies (Confusion me, double *out_h, double *out_hx, double *out_hy, |
| 51 |
double *out_hygx, double *out_hxgy, double *out_uygx, double *out_uxgy, double *out_uxy); |
| 52 |
/* x is column variable, y is row variable |
| 53 |
*out_h entropy of whole table; |
| 54 |
*out_hx entropy of x variable |
| 55 |
*out_hy entropy of y variable |
| 56 |
*out_hygx entropy of y given x |
| 57 |
*out_hxgy entropy of x given y |
| 58 |
*out_uygx dependency of y on x |
| 59 |
*out_uxgy dependency of x on y |
| 60 |
*out_uxy symmetrical dependency |
| 61 |
*/ |
| 62 |
|
| 63 |
void Confusion_getFractionCorrect (Confusion me, double *out_fraction, integer *out_numberOfCorrect); |
| 64 |
|
| 65 |
void Confusion_Matrix_draw (Confusion me, Matrix thee, Graphics g, integer index, double lowerPercentage, double xmin, double xmax, double ymin, double ymax, bool garnish); |
| 66 |
/* 1. Draw my rowLabels centered at ( matrix->z [i] [1], matrix -> z [i] [2]). |
| 67 |
2. Draw arrows and circles according to: |
| 68 |
for (i=1; i <= my numberOfRows; i++) |
| 69 |
{ |
| 70 |
if (index != 0 && index != i) continue; |
| 71 |
draw circle at i of width: my z [i] [i] / rowSum; |
| 72 |
for (j=1; j <= my numberOfColumns; j++) |
| 73 |
{ |
| 74 |
if (i != j && 100*my data [i] [j] / rowSum > lowerPercentage) |
| 75 |
draw arrow from i to j of width: my data [i] [j] / rowSum; |
| 76 |
} |
| 77 |
} |
| 78 |
*/ |
| 79 |
|
| 80 |
autoMatrix Confusion_difference (Confusion me, Confusion thee); |
| 81 |
/* return matrix with the difference between the two confusion matrices */ |
| 82 |
|
| 83 |
integer Confusion_getNumberOfEntries (Confusion me); |
| 84 |
|
| 85 |
autoConfusion Confusion_groupStimuli (Confusion me, conststring32 labels, conststring32 newLabel, integer newpos); |
| 86 |
|
| 87 |
autoConfusion Confusion_groupResponses (Confusion me, conststring32 labels, conststring32 newLabel, integer newpos); |
| 88 |
|
| 89 |
autoConfusion Confusion_group (Confusion me, conststring32 labels, conststring32 newLabel, integer newpos); |
| 90 |
|
| 91 |
autoConfusion Confusion_condense (Confusion me, conststring32 search, conststring32 replace, integer maximumNumberOfReplaces, bool use_regexp); |
| 92 |
/* |
| 93 |
Group row and column labels according to search and replace. |
| 94 |
*/ |
| 95 |
|
| 96 |
autoConfusion TableOfReal_to_Confusion (TableOfReal me); |
| 97 |
|
| 98 |
autoTableOfReal Confusion_to_TableOfReal_marginals (Confusion me); |
| 99 |
/* |
| 100 |
Create a table with one extra row and one extra column with marginals, |
| 101 |
i.e., column and row sums. |
| 102 |
*/ |
| 103 |
|
| 104 |
void Confusion_drawAsNumbers (Confusion me, Graphics g, bool marginals, int iformat, int precision); |
| 105 |
/* option marginals draw one extra row and column with marginal sums. */ |
| 106 |
|
| 107 |
#endif /* _Confusion_h_ */ |