+
+static void
+output_classification_table (const struct lr_spec *cmd, const struct lr_result *res)
+{
+ const struct fmt_spec *wfmt =
+ cmd->wv ? var_get_print_format (cmd->wv) : &F_8_0;
+
+ const int heading_columns = 3;
+ const int heading_rows = 3;
+
+ struct string sv0, sv1;
+
+ const int nc = heading_columns + 3;
+ const int nr = heading_rows + 3;
+
+ struct tab_table *t = tab_create (nc, nr);
+ tab_set_format (t, RC_WEIGHT, wfmt);
+
+ ds_init_empty (&sv0);
+ ds_init_empty (&sv1);
+
+ tab_title (t, _("Classification Table"));
+
+ tab_headers (t, heading_columns, 0, heading_rows, 0);
+
+ tab_box (t, TAL_2, TAL_2, -1, -1, 0, 0, nc - 1, nr - 1);
+ tab_box (t, -1, -1, -1, TAL_1, heading_columns, 0, nc - 1, nr - 1);
+
+ tab_hline (t, TAL_2, 0, nc - 1, heading_rows);
+ tab_vline (t, TAL_2, heading_columns, 0, nr - 1);
+
+ tab_text (t, 0, heading_rows, TAB_CENTER | TAT_TITLE, _("Step 1"));
+
+
+ tab_joint_text (t, heading_columns, 0, nc - 1, 0,
+ TAB_CENTER | TAT_TITLE, _("Predicted"));
+
+ tab_joint_text (t, heading_columns, 1, heading_columns + 1, 1,
+ 0, var_to_string (cmd->dep_var) );
+
+ tab_joint_text (t, 1, 2, 2, 2,
+ TAB_LEFT | TAT_TITLE, _("Observed"));
+
+ tab_text (t, 1, 3, TAB_LEFT, var_to_string (cmd->dep_var) );
+
+
+ tab_joint_text (t, nc - 1, 1, nc - 1, 2,
+ TAB_CENTER | TAT_TITLE, _("Percentage\nCorrect"));
+
+
+ tab_joint_text (t, 1, nr - 1, 2, nr - 1,
+ TAB_LEFT | TAT_TITLE, _("Overall Percentage"));
+
+
+ tab_hline (t, TAL_1, 1, nc - 1, nr - 1);
+
+ var_append_value_name (cmd->dep_var, &res->y0, &sv0);
+ var_append_value_name (cmd->dep_var, &res->y1, &sv1);
+
+ tab_text (t, 2, heading_rows, TAB_LEFT, ds_cstr (&sv0));
+ tab_text (t, 2, heading_rows + 1, TAB_LEFT, ds_cstr (&sv1));
+
+ tab_text (t, heading_columns, 2, 0, ds_cstr (&sv0));
+ tab_text (t, heading_columns + 1, 2, 0, ds_cstr (&sv1));
+
+ ds_destroy (&sv0);
+ ds_destroy (&sv1);
+
+ tab_double (t, heading_columns, 3, 0, res->tn, NULL, RC_WEIGHT);
+ tab_double (t, heading_columns + 1, 4, 0, res->tp, NULL, RC_WEIGHT);
+
+ tab_double (t, heading_columns + 1, 3, 0, res->fp, NULL, RC_WEIGHT);
+ tab_double (t, heading_columns, 4, 0, res->fn, NULL, RC_WEIGHT);
+
+ tab_double (t, heading_columns + 2, 3, 0, 100 * res->tn / (res->tn + res->fp), NULL, RC_OTHER);
+ tab_double (t, heading_columns + 2, 4, 0, 100 * res->tp / (res->tp + res->fn), NULL, RC_OTHER);
+
+ tab_double (t, heading_columns + 2, 5, 0,
+ 100 * (res->tp + res->tn) / (res->tp + res->tn + res->fp + res->fn), NULL, RC_OTHER);
+
+
+ tab_submit (t);
+}