in reply to plotting roc curve using roc package
Hello numita, and welcome to the Monastery!
I can see three problems with your code (there might be others):
First, you do not have:
use strict; use warnings;
at the head of your script. Get into the habit of always adding these pragmata, and of using lexical variables whenever possible.
Second, this loop:
while ( <fh> ) { ($a,$b)=split/,/; push @AoA, [ split ]; }
almost certainly doesn’t do what you want. The first call to split does nothing (because the results are never used); the second call results in @AoA containing this (obtained via Data::Dump):
[ "0.9883817,1", "0.770431568,1", "0.983195895,1", "0.812109932,1", "0.901505931,1", "0.72431528,1", "0.73553418,1", "0.724572657,1", ]
What you need is something like this:
#! perl use strict; use warnings; use Statistics::ROC; use Data::Dump; my @AoA; while (<DATA>) { my @pairs = split; push @AoA, [ split /,/ ] for @pairs; } dd @AoA; my @curves = roc('decrease', 0.95, @AoA); print "$curves[0][2][0] $curves[0][2][1]\n"; __DATA__ 0.9883817,1 0.770431568,1 0.983195895,1 0.812109932,1 0.901505931,1 0.72431528,1 0.73553418,1 0.724572657,1
which produces the following output:
17:41 >perl 1327_SoPW.pl ( [0.9883817, 1], [0.770431568, 1], [0.983195895, 1], [0.812109932, 1], [0.901505931, 1], [0.72431528, 1], [0.73553418, 1], [0.724572657, 1], ) Value out of range for table lookup (2): 0.72431528. at 1327_SoPW.pl line 45. 17:45 >
Well, we’re getting closer, but we’re still getting the same error message. Which brings us to the third problem: the input data is almost certainly incorrect. In the examples given in Statistics::ROC’s documentation, the second “true” value in each data pair is zero (i.e. false) for around half the pairs. In your data, the second value is always 1 (true). I’m no mathematician, but I’m guessing that the input data you have supplied is invalid (or at least incomplete) for this algorithm.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|