AI-ConfusionMatrix
view release on metacpan or search on metacpan
Change: d73032ef2fcefce4a9dadba0be174ae13cd9ab71
Author: Vincent Lequertier <vi.le@autistici.org>
Date : 2017-11-08 21:52:05 +0000
Compute the sensitivity
Change: cbff868057b49d9ffbe285f8528be62223bab061
Author: Vincent Lequertier <vi.le@autistici.org>
Date : 2017-11-08 21:31:10 +0000
Append the '%' in the sprintf
Change: b85dc7c2c4789db4e877f3b233ccea84c0830c5f
Author: Vincent Lequertier <vi.le@autistici.org>
Date : 2017-04-29 19:18:16 +0000
adds .travis.yml
Change: 76c1eaab4b36e158af61e053e7db7d7dad48c268
Author: Vincent Lequertier <vi.le@autistici.org>
Date : 2017-01-18 21:34:50 +0000
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.
# [...]
$matrix{$expected}{$predicted} += 1;
# [...]
makeConfusionMatrix(\%matrix, 'output.csv');
# DESCRIPTION
This module prints a [confusion matrix](https://en.wikipedia.org/wiki/Confusion_matrix) from a hash reference. This module tries to be generic enough to be used within a lot of machine learning projects.
### Functions:
#### `makeConfusionMatrix($hash_ref, $file [, $delimiter ])`
This function makes a confusion matrix from `$hash_ref` and writes it to `$file`. `$file` can be a filename or a file handle opened with the `w+` mode. If `$delimiter` is present, it is used as a custom separator for the fields in the confusion matri...
Examples:
makeConfusionMatrix(\%matrix, 'output.csv');
lib/AI/ConfusionMatrix.pm view on Meta::CPAN
$lastIndex = $index;
}
# Get to the columns of the stats
$output_array[$line] .= $delem x (scalar(@columns) - $lastIndex + 1);
$output_array[$line] .= join $delem, (
$cmData{stats}{$expected}{'total'},
$cmData{stats}{$expected}{'tp'},
$cmData{stats}{$expected}{'fp'},
$cmData{stats}{$expected}{'fn'},
sprintf('%.2f%%', $cmData{stats}{$expected}{'sensitivity'}),
sprintf('%.2f%%', $cmData{stats}{$expected}{'acc'})
);
++$line;
}
# Print the TOTAL row to the csv file
$output_array[$line] = 'TOTAL' . $delem;
map {$output_array[$line] .= $cmData{totals}{$_} . $delem} (@columns);
$output_array[$line] .= join $delem, (
$cmData{totals}{'total'},
$cmData{totals}{'tp'},
$cmData{totals}{'fp'},
$cmData{totals}{'fn'},
sprintf('%.2f%%', $cmData{totals}{'sensitivity'}),
sprintf('%.2f%%', $cmData{totals}{'acc'})
);
untie @output_array;
}
sub getConfusionMatrix {
my ($matrix) = @_;
carp ('First argument must be a hash reference') if ref($matrix) ne 'HASH';
return genConfusionMatrixData($matrix);
lib/AI/ConfusionMatrix.pm view on Meta::CPAN
$matrix{$expected}{$predicted} += 1;
# [...]
makeConfusionMatrix(\%matrix, 'output.csv');
=head1 DESCRIPTION
This module prints a L<confusion matrix|https://en.wikipedia.org/wiki/Confusion_matrix> from a hash reference. This module tries to be generic enough to be used within a lot of machine learning projects.
=head3 Functions:
=head4 C<makeConfusionMatrix($hash_ref, $file [, $delimiter ])>
This function makes a confusion matrix from C<$hash_ref> and writes it to C<$file>. C<$file> can be a filename or a file handle opened with the C<w+> mode. If C<$delimiter> is present, it is used as a custom separator for the fields in the confusion ...
Examples:
makeConfusionMatrix(\%matrix, 'output.csv');
( run in 0.519 second using v1.01-cache-2.11-cpan-de7293f3b23 )