| 1 | #cxx . . $ `<file>/dwtools/Confusion.h`/ifndef _Confusion_h_ |
| 2 | #define _Confusion_h_cxx . . $ `dwtools/Confusion.h:2:9`! |
| 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"cxx . . $ `<file>/stat/TableOfReal.h`/ |
| 22 | #include "Categories.h"cxx . . $ `<file>/dwtools/Categories.h`/ |
| 23 | #include "Graphics.h"cxx . . $ `<file>/sys/Graphics.h`/ |
| 24 | #include "Matrix.h"cxx . . $ `<file>/fon/Matrix.h`/ |
| 25 | |
| 26 | Thing_definecxx . . $ Confusion# (Confusion, TableOfReal) { |
| 27 | void v1_infocxx . . $ structConfusion#v1_info(49f6e7a06ebc5aa8). () |
| 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 | autoConfusioncxx . . $ autoConfusion# Confusion_createcxx . . $ Confusion_create(427de3c2cd3df832). (integercxx . . $ integer# numberOfStimuli, integercxx . . $ integer# numberOfResponses); |
| 37 | |
| 38 | autoConfusioncxx . . $ autoConfusion# Confusion_createSimplecxx . . $ Confusion_createSimple(5120f448f1dd1a26). (conststring32cxx . . $ conststring32# labels); |
| 39 | |
| 40 | autoConfusioncxx . . $ autoConfusion# Confusion_createFromStringsescxx . . $ Confusion_createFromStringses(5db7a5f4207d480c). (Stringscxx . . $ Strings# stimulusLabels, Stringscxx . . $ Strings# responseLabels); |
| 41 | |
| 42 | autoConfusioncxx . . $ autoConfusion# Categories_to_Confusioncxx . . $ Categories_to_Confusion(4394f8a90f775872). (Categoriescxx . . $ Categories# me, Categoriescxx . . $ Categories# thee); |
| 43 | |
| 44 | void Confusion_increasecxx . . $ Confusion_increase(60c4476b94ec172e). (Confusioncxx . . $ Confusion# me, conststring32cxx . . $ conststring32# stimulus, conststring32cxx . . $ conststring32# response); |
| 45 | /* Increase the confusion count by one: data ['stim'] ['resp'] += 1; */ |
| 46 | |
| 47 | double Confusion_getValuecxx . . $ Confusion_getValue(4b97e97d0ec63c17). (Confusioncxx . . $ Confusion# me, conststring32cxx . . $ conststring32# stimulus, conststring32cxx . . $ conststring32# response); |
| 48 | /* data ['stim'] ['resp'] ; */ |
| 49 | |
| 50 | void Confusion_getEntropiescxx . . $ Confusion_getEntropies(e8a94b367b71789b). (Confusioncxx . . $ 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_getFractionCorrectcxx . . $ Confusion_getFractionCorrect(fadeb705c51e4413). (Confusioncxx . . $ Confusion# me, double *out_fraction, integercxx . . $ integer# *out_numberOfCorrect); |
| 64 | |
| 65 | void Confusion_Matrix_drawcxx . . $ Confusion_Matrix_draw(6322a3a4de977905). (Confusioncxx . . $ Confusion# me, Matrixcxx . . $ Matrix# thee, Graphicscxx . . $ Graphics# g, integercxx . . $ 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 | autoMatrixcxx . . $ autoMatrix# Confusion_differencecxx . . $ Confusion_difference(b60711367560390a). (Confusioncxx . . $ Confusion# me, Confusioncxx . . $ Confusion# thee); |
| 81 | /* return matrix with the difference between the two confusion matrices */ |
| 82 | |
| 83 | integercxx . . $ integer# Confusion_getNumberOfEntriescxx . . $ Confusion_getNumberOfEntries(e3f71f15894d039c). (Confusioncxx . . $ Confusion# me); |
| 84 | |
| 85 | autoConfusioncxx . . $ autoConfusion# Confusion_groupStimulicxx . . $ Confusion_groupStimuli(5de673d58d2532c0). (Confusioncxx . . $ Confusion# me, conststring32cxx . . $ conststring32# labels, conststring32cxx . . $ conststring32# newLabel, integercxx . . $ integer# newpos); |
| 86 | |
| 87 | autoConfusioncxx . . $ autoConfusion# Confusion_groupResponsescxx . . $ Confusion_groupResponses(5de673d58d2532c0). (Confusioncxx . . $ Confusion# me, conststring32cxx . . $ conststring32# labels, conststring32cxx . . $ conststring32# newLabel, integercxx . . $ integer# newpos); |
| 88 | |
| 89 | autoConfusioncxx . . $ autoConfusion# Confusion_groupcxx . . $ Confusion_group(5de673d58d2532c0). (Confusioncxx . . $ Confusion# me, conststring32cxx . . $ conststring32# labels, conststring32cxx . . $ conststring32# newLabel, integercxx . . $ integer# newpos); |
| 90 | |
| 91 | autoConfusioncxx . . $ autoConfusion# Confusion_condensecxx . . $ Confusion_condense(727e6577c6a29c4f). (Confusioncxx . . $ Confusion# me, conststring32cxx . . $ conststring32# search, conststring32cxx . . $ conststring32# replace, integercxx . . $ integer# maximumNumberOfReplaces, bool use_regexp); |
| 92 | /* |
| 93 | Group row and column labels according to search and replace. |
| 94 | */ |
| 95 | |
| 96 | autoConfusioncxx . . $ autoConfusion# TableOfReal_to_Confusioncxx . . $ TableOfReal_to_Confusion(98d4fd466ea95203). (TableOfRealcxx . . $ TableOfReal# me); |
| 97 | |
| 98 | autoTableOfRealcxx . . $ autoTableOfReal# Confusion_to_TableOfReal_marginalscxx . . $ Confusion_to_TableOfReal_marginals(678fb612a1edde02). (Confusioncxx . . $ 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_drawAsNumberscxx . . $ Confusion_drawAsNumbers(1aac77270b3aa2ee). (Confusioncxx . . $ Confusion# me, Graphicscxx . . $ 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_ */ |