}
+/* Prepare the cutpoints */
static void
-do_roc (struct cmd_roc *roc, struct casereader *input, struct dictionary *dict)
+prepare_cutpoints (struct cmd_roc *roc, struct roc_state *rs, struct casereader *input)
{
int i;
+ struct casereader *r = casereader_clone (input);
+ struct ccase *c;
+ struct caseproto *proto = caseproto_create ();
- struct roc_state *rs = xcalloc (roc->n_vars, sizeof *rs);
+ struct subcase ordering;
+ subcase_init (&ordering, CUTPOINT, 0, SC_ASCEND);
- struct casewriter *neg_wtr = autopaging_writer_create (casereader_get_proto (input));
+ proto = caseproto_add_width (proto, 0); /* cutpoint */
+ proto = caseproto_add_width (proto, 0); /* TP */
+ proto = caseproto_add_width (proto, 0); /* FN */
+ proto = caseproto_add_width (proto, 0); /* TN */
+ proto = caseproto_add_width (proto, 0); /* FP */
- struct casereader *negatives = NULL;
- struct casereader *positives = NULL;
+ for (i = 0 ; i < roc->n_vars; ++i)
+ {
+ rs[i].cutpoint_wtr = sort_create_writer (&ordering, proto);
+ rs[i].prev_result = SYSMIS;
+ rs[i].max = -DBL_MAX;
+ rs[i].min = DBL_MAX;
+ }
- struct caseproto *n_proto = caseproto_create ();
+ for (; (c = casereader_read (r)) != NULL; case_unref (c))
+ {
+ for (i = 0 ; i < roc->n_vars; ++i)
+ {
+ const double result = case_data (c, roc->vars[i])->f;
- struct subcase up_ordering;
- struct subcase down_ordering;
+ minimize (&rs[i].min, result);
+ maximize (&rs[i].max, result);
- /* Prepare the cutpoints */
- {
- struct casereader *r = casereader_clone (input);
- struct ccase *c;
- struct caseproto *proto = caseproto_create ();
+ if ( rs[i].prev_result != SYSMIS && rs[i].prev_result != result )
+ {
+ const double mean = (result + rs[i].prev_result ) / 2.0;
+ append_cutpoint (rs[i].cutpoint_wtr, mean);
+ }
- struct subcase ordering;
- subcase_init (&ordering, CUTPOINT, 0, SC_ASCEND);
+ rs[i].prev_result = result;
+ }
+ }
+ casereader_destroy (r);
- proto = caseproto_add_width (proto, 0); /* cutpoint */
- proto = caseproto_add_width (proto, 0); /* TP */
- proto = caseproto_add_width (proto, 0); /* FN */
- proto = caseproto_add_width (proto, 0); /* TN */
- proto = caseproto_add_width (proto, 0); /* FP */
+ /* Append the min and max cutpoints */
+ for (i = 0 ; i < roc->n_vars; ++i)
+ {
+ append_cutpoint (rs[i].cutpoint_wtr, rs[i].min - 1);
+ append_cutpoint (rs[i].cutpoint_wtr, rs[i].max + 1);
- for (i = 0 ; i < roc->n_vars; ++i)
- {
- rs[i].cutpoint_wtr = sort_create_writer (&ordering, proto);
- rs[i].prev_result = SYSMIS;
- rs[i].max = -DBL_MAX;
- rs[i].min = DBL_MAX;
- }
+ rs[i].cutpoint_rdr = casewriter_make_reader (rs[i].cutpoint_wtr);
+ }
+}
- for (; (c = casereader_read (r)) != NULL; case_unref (c))
- {
- for (i = 0 ; i < roc->n_vars; ++i)
- {
- const double result = case_data (c, roc->vars[i])->f;
+static void
+do_roc (struct cmd_roc *roc, struct casereader *input, struct dictionary *dict)
+{
+ int i;
- minimize (&rs[i].min, result);
- maximize (&rs[i].max, result);
+ struct roc_state *rs = xcalloc (roc->n_vars, sizeof *rs);
- if ( rs[i].prev_result != SYSMIS && rs[i].prev_result != result )
- {
- const double mean = (result + rs[i].prev_result ) / 2.0;
- append_cutpoint (rs[i].cutpoint_wtr, mean);
- }
+ struct casewriter *neg_wtr = autopaging_writer_create (casereader_get_proto (input));
- rs[i].prev_result = result;
- }
- }
- casereader_destroy (r);
+ struct casereader *negatives = NULL;
+ struct casereader *positives = NULL;
+ struct caseproto *n_proto = caseproto_create ();
- /* Append the min and max cutpoints */
- for (i = 0 ; i < roc->n_vars; ++i)
- {
- append_cutpoint (rs[i].cutpoint_wtr, rs[i].min - 1);
- append_cutpoint (rs[i].cutpoint_wtr, rs[i].max + 1);
+ struct subcase up_ordering;
+ struct subcase down_ordering;
- rs[i].cutpoint_rdr = casewriter_make_reader (rs[i].cutpoint_wtr);
- }
- }
+ prepare_cutpoints (roc, rs, input);
positives =
casereader_create_filter_func (input,