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,


In reply to Re: plotting roc curve using roc package by Athanasius
in thread plotting roc curve using roc package by numita

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.