# DDESONN — Plot Controls — Scenario 1 & 2 — Single Run: Scenario A

## Plot Interface — Scenario 1 vs Scenario 2

This vignette demonstrates two supported plot configuration interfaces in DDESONN.

### Scenario 1 — Independent Call Sites (`training_overrides`)

Scenario 1 configures plotting through three independent call sites inside `training_overrides`:

1. `training_overrides$per_epoch_plots`
2. `training_overrides$performance_relevance`
3. `training_overrides$evaluate_predictions_report_plots`

Each plot category is configured separately.
This represents the minimal integration bridge interface.

For the unified umbrella interface (recommended), see:

`plot-controls_scenario1-2_single-run_scenarioA.Rmd`

### Scenario 2 — Unified Umbrella (`plot_controls`)

Scenario 2 configures all plots through a single unified interface:

- `plot_controls`

All plot categories (e.g., `per_epoch`, `performance_relevance`, `evaluate_report`) are defined under this one umbrella.

For comparison with the three-call-site structure (Scenario 1), see:

`plot-controls_scenario1-2_single-run_scenarioA.Rmd`

[PR] RESOLVED pr_cfg for update_performance_and_relevance (ensemble_number=0, do_ensemble=FALSE) list(saveEnabled = TRUE, viewAllPlots = FALSE, performance_high_mean_plots = TRUE, performance_low_mean_plots = TRUE, relevance_high_mean_plots = TRUE, relevance_low_mean_plots = TRUE, verbose = TRUE) [PR] knitr.in.progress=TRUE [PR] interactive()=FALSE [PR] option(DDESONN_OUTPUT_ROOT)=C:6f9Ge/ddesonn-vig-s1-s2/outputs/DDESONN_plots_scenarioA_s1 [PR] env(DDESONN_ARTIFACTS_ROOT)=C:6f9Ge/ddesonn-vig-s1-s2/outputs/DDESONN_plots_scenarioA_s1 [PR] run_id (head): Ensemble: 0 Model: 1 (n=1) [PR] pr_saveEnabled=TRUE [PR] pr_viewAllPlots=FALSE [PR] flags resolved (post viewAll): perf_high=TRUE perf_low=TRUE relev_high=TRUE relev_low=TRUE [PR TRACE] pr_viewAllPlots= FALSE pr_saveEnabled= TRUE [PR TRACE] rows: perf_high= 7 perf_low= 36 relev_high= 0 relev_low= 3 [PR TRACE] print_plots=TRUE [PR TRACE] CALL high(perf) [PR] performance_high_mean_plots class=list length=7 names(head)=confusion_matrix_TP,confusion_matrix_FP,confusion_matrix_TN,accuracy_precision_recall_f1_tuned_confusion_matrix_TP,accuracy_precision_recall_f1_tuned_confusion_matrix_TN [PR TRACE] CALL low(perf) [PR] performance_low_mean_plots class=list length=36 names(head)=quantization_error,topographic_error,clustering_quality_db,MSE,MAE [PR TRACE] CALL high(relev) [PR] relevance_high_mean_plots class=list length=0 [PR TRACE] CALL low(relev) [PR] relevance_low_mean_plots class=list length=3 names(head)=ndcg,diversity,serendipity

    # ================================================================================
    # ================================= CORE METRICS =================================
    # ================================================================================

    ===== FINAL SUMMARY =====
    Best epoch          : 167
    Train accuracy      : 0.990000
    Val accuracy        : 0.984000
    Train loss          : 0.008937
    Val loss            : 0.013941
    Threshold           : 0.500000
    Test accuracy       : 0.988000
    Test loss           : 0.058435

===== TRAIN =====

Classification Report

| precision | recall | f1-score | support
--- | --- | --- | --- | ---
0 | 0.996275 | 0.997927 | 0.997100 | 2412.000000
1 | 0.995387 | 0.991728 | 0.993554 | 1088.000000
accuracy | 0.996000 | 0.996000 | 0.996000 | 3500.000000
macro avg | 0.995831 | 0.994827 | 0.995327 | 3500.000000
weighted avg | 0.995999 | 0.996000 | 0.995998 | 3500.000000

Confusion Matrix

| Positive (1) | Negative (0)
--- | --- | ---
Positive (1) | 1079 | 5
Negative (0) | 9 | 2407

AUC/AUPRC AUC (ROC): 0.999922 AUPRC: 0.999831

===== VALIDATION =====

Classification Report

| precision | recall | f1-score | support
--- | --- | --- | --- | ---
0 | 0.991718 | 0.977551 | 0.984584 | 490.000000
1 | 0.958801 | 0.984615 | 0.971537 | 260.000000
accuracy | 0.980000 | 0.980000 | 0.980000 | 750.000000
macro avg | 0.975260 | 0.981083 | 0.978060 | 750.000000
weighted avg | 0.980307 | 0.980000 | 0.980061 | 750.000000

Confusion Matrix

| Positive (1) | Negative (0)
--- | --- | ---
Positive (1) | 256 | 11
Negative (0) | 4 | 479

AUC/AUPRC AUC (ROC): 0.992708 AUPRC: 0.986047

===== TEST =====

Classification Report

| precision | recall | f1-score | support
--- | --- | --- | --- | ---
0 | 0.998088 | 0.984906 | 0.991453 | 530.000000
1 | 0.964758 | 0.995455 | 0.979866 | 220.000000
accuracy | 0.988000 | 0.988000 | 0.988000 | 750.000000
macro avg | 0.981423 | 0.990180 | 0.985659 | 750.000000
weighted avg | 0.988311 | 0.988000 | 0.988054 | 750.000000

Confusion Matrix

| Positive (1) | Negative (0)
--- | --- | ---
Positive (1) | 219 | 8
Negative (0) | 1 | 522

AUC/AUPRC AUC (ROC): 0.996964 AUPRC: 0.996219

## Scenario 1 — Saved plots

## Scenario 2 — One `plot_controls` umbrella (Single Run: Scenario A)

    options(DDESONN_OUTPUT_ROOT = if (is_check_env) .vig_tmp_root else out2)
    Sys.setenv(DDESONN_ARTIFACTS_ROOT = if (is_check_env) .vig_tmp_root else out2)

    res_scenarioA_s2 <- ddesonn_run(
      x = x_train,
      y = y_train,
      classification_mode = "binary",
      hidden_sizes = c(64, 32),
      seeds = 1L,
      do_ensemble = FALSE,
      validation = list(x = x_valid, y = y_valid),
      test       = list(x = x_test,  y = y_test),
      training_overrides = list(
        init_method = "he",
        optimizer = "adagrad",
        lr = 0.125,
        lambda = 0.00028,
        activation_functions = list(relu, relu, sigmoid),
        dropout_rates = list(0.10),
        loss_type = "CrossEntropy",
        validation_metrics = TRUE,
        num_epochs = 1,
        final_summary_decimals = 6L
      ),
      plot_controls = list(
        per_epoch = list(
          saveEnabled = !is_check_env,
          loss_curve = TRUE,
          probe_plots = TRUE,
          verbose = TRUE
        ),

        # ============================================================
        #  SECTION: performance_relevance (Scenario 2)
        # ============================================================
        performance_relevance = list(
          saveEnabled = !is_check_env,
          viewAllPlots = FALSE,
          performance_high_mean_plots = TRUE,
          performance_low_mean_plots  = TRUE,
          relevance_high_mean_plots   = TRUE,
          relevance_low_mean_plots    = TRUE,
          verbose = TRUE
        ),

        evaluate_report = list(
          accuracy_plot = TRUE,
          accuracy_plot_mode = "both",
          plot_roc = TRUE,
          plot_pr  = TRUE,
          show_auprc = TRUE,
          viewAllPlots = FALSE,
          verbose = TRUE
        )
      )
    )

    ## [PR] RESOLVED pr_cfg for update_performance_and_relevance (ensemble_number=0, do_ensemble=FALSE)
    ## list(saveEnabled = TRUE, viewAllPlots = FALSE, performance_high_mean_plots = TRUE,
    ##     performance_low_mean_plots = TRUE, relevance_high_mean_plots = TRUE,
    ##     relevance_low_mean_plots = TRUE, verbose = TRUE)
    ## [PR] knitr.in.progress=TRUE
    ## [PR] interactive()=FALSE
    ## [PR] option(DDESONN_OUTPUT_ROOT)=C:\Users\wfky1\AppData\Local\Temp\RtmpK6f9Ge/ddesonn-vig-s1-s2/outputs/DDESONN_plots_scenarioA_s2
    ## [PR] env(DDESONN_ARTIFACTS_ROOT)=C:\Users\wfky1\AppData\Local\Temp\RtmpK6f9Ge/ddesonn-vig-s1-s2/outputs/DDESONN_plots_scenarioA_s2
    ## [PR] run_id (head): Ensemble: 0 Model: 1 (n=1)
    ## [PR] pr_saveEnabled=TRUE
    ## [PR] pr_viewAllPlots=FALSE
    ## [PR] flags resolved (post viewAll): perf_high=TRUE perf_low=TRUE relev_high=TRUE relev_low=TRUE
    ## [PR TRACE] pr_viewAllPlots= FALSE  pr_saveEnabled= TRUE
    ## [PR TRACE] rows: perf_high= 9  perf_low= 18  relev_high= 0  relev_low= 3
    ## [PR TRACE] print_plots=TRUE
    ## [PR TRACE] CALL high(perf)

    ## [PR] performance_high_mean_plots class=list length=9 names(head)=confusion_matrix_TP,confusion_matrix_FP,confusion_matrix_TN,confusion_matrix_FN,accuracy_precision_recall_f1_tuned_confusion_matrix_TP
    ## [PR TRACE] CALL low(perf)

    ## [PR] performance_low_mean_plots class=list length=18 names(head)=quantization_error,topographic_error,clustering_quality_db,MSE,MAE
    ## [PR TRACE] CALL high(relev)
    ## [PR] relevance_high_mean_plots class=list length=0
    ## [PR TRACE] CALL low(relev)

    ## [PR] relevance_low_mean_plots class=list length=3 names(head)=ndcg,diversity,serendipity

    ##
    ## ```text
    ##
    ## # ================================================================================
    ## # ================================= CORE METRICS =================================
    ## # ================================================================================
    ##
    ## ===== FINAL SUMMARY =====
    ## Best epoch          : 1
    ## Train accuracy      : 0.493429
    ## Val accuracy        : 0.697333
    ## Train loss          : 0.253650
    ## Val loss            : 0.206287
    ## Threshold           : 0.650000
    ## Test accuracy       : 0.801333
    ## Test loss           : 0.628412
    ## ```
    ##
    ## ===== TRAIN =====
    ##
    ## Classification Report
    ## <table>
    ##  <thead>
    ##   <tr>
    ##    <th style="text-align:left;">   </th>
    ##    <th style="text-align:left;"> precision </th>
    ##    <th style="text-align:left;"> recall </th>
    ##    <th style="text-align:left;"> f1-score </th>
    ##    <th style="text-align:left;"> support </th>
    ##   </tr>
    ##  </thead>
    ## <tbody>
    ##   <tr>
    ##    <td style="text-align:left;"> 0 </td>
    ##    <td style="text-align:left;"> 0.871505 </td>
    ##    <td style="text-align:left;"> 0.607380 </td>
    ##    <td style="text-align:left;"> 0.715856 </td>
    ##    <td style="text-align:left;"> 2412.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> 1 </td>
    ##    <td style="text-align:left;"> 0.479384 </td>
    ##    <td style="text-align:left;"> 0.801471 </td>
    ##    <td style="text-align:left;"> 0.599931 </td>
    ##    <td style="text-align:left;"> 1088.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> accuracy </td>
    ##    <td style="text-align:left;"> 0.667714 </td>
    ##    <td style="text-align:left;"> 0.667714 </td>
    ##    <td style="text-align:left;"> 0.667714 </td>
    ##    <td style="text-align:left;"> 3500.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> macro avg </td>
    ##    <td style="text-align:left;"> 0.675445 </td>
    ##    <td style="text-align:left;"> 0.704425 </td>
    ##    <td style="text-align:left;"> 0.657894 </td>
    ##    <td style="text-align:left;"> 3500.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> weighted avg </td>
    ##    <td style="text-align:left;"> 0.749612 </td>
    ##    <td style="text-align:left;"> 0.667714 </td>
    ##    <td style="text-align:left;"> 0.679820 </td>
    ##    <td style="text-align:left;"> 3500.000000 </td>
    ##   </tr>
    ## </tbody>
    ## </table>
    ##
    ## Confusion Matrix
    ## <table>
    ##  <thead>
    ##   <tr>
    ##    <th style="text-align:left;">   </th>
    ##    <th style="text-align:right;"> Positive (1) </th>
    ##    <th style="text-align:right;"> Negative (0) </th>
    ##   </tr>
    ##  </thead>
    ## <tbody>
    ##   <tr>
    ##    <td style="text-align:left;"> Positive (1) </td>
    ##    <td style="text-align:right;"> 872 </td>
    ##    <td style="text-align:right;"> 947 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> Negative (0) </td>
    ##    <td style="text-align:right;"> 216 </td>
    ##    <td style="text-align:right;"> 1465 </td>
    ##   </tr>
    ## </tbody>
    ## </table>
    ##
    ## AUC/AUPRC
    ## AUC (ROC): 0.809206
    ## AUPRC: 0.713748
    ##
    ## ===== VALIDATION =====
    ##
    ## Classification Report
    ## <table>
    ##  <thead>
    ##   <tr>
    ##    <th style="text-align:left;">   </th>
    ##    <th style="text-align:left;"> precision </th>
    ##    <th style="text-align:left;"> recall </th>
    ##    <th style="text-align:left;"> f1-score </th>
    ##    <th style="text-align:left;"> support </th>
    ##   </tr>
    ##  </thead>
    ## <tbody>
    ##   <tr>
    ##    <td style="text-align:left;"> 0 </td>
    ##    <td style="text-align:left;"> 0.892537 </td>
    ##    <td style="text-align:left;"> 0.610204 </td>
    ##    <td style="text-align:left;"> 0.724848 </td>
    ##    <td style="text-align:left;"> 490.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> 1 </td>
    ##    <td style="text-align:left;"> 0.539759 </td>
    ##    <td style="text-align:left;"> 0.861538 </td>
    ##    <td style="text-align:left;"> 0.663704 </td>
    ##    <td style="text-align:left;"> 260.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> accuracy </td>
    ##    <td style="text-align:left;"> 0.697333 </td>
    ##    <td style="text-align:left;"> 0.697333 </td>
    ##    <td style="text-align:left;"> 0.697333 </td>
    ##    <td style="text-align:left;"> 750.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> macro avg </td>
    ##    <td style="text-align:left;"> 0.716148 </td>
    ##    <td style="text-align:left;"> 0.735871 </td>
    ##    <td style="text-align:left;"> 0.694276 </td>
    ##    <td style="text-align:left;"> 750.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> weighted avg </td>
    ##    <td style="text-align:left;"> 0.770241 </td>
    ##    <td style="text-align:left;"> 0.697333 </td>
    ##    <td style="text-align:left;"> 0.703652 </td>
    ##    <td style="text-align:left;"> 750.000000 </td>
    ##   </tr>
    ## </tbody>
    ## </table>
    ##
    ## Confusion Matrix
    ## <table>
    ##  <thead>
    ##   <tr>
    ##    <th style="text-align:left;">   </th>
    ##    <th style="text-align:right;"> Positive (1) </th>
    ##    <th style="text-align:right;"> Negative (0) </th>
    ##   </tr>
    ##  </thead>
    ## <tbody>
    ##   <tr>
    ##    <td style="text-align:left;"> Positive (1) </td>
    ##    <td style="text-align:right;"> 224 </td>
    ##    <td style="text-align:right;"> 191 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> Negative (0) </td>
    ##    <td style="text-align:right;"> 36 </td>
    ##    <td style="text-align:right;"> 299 </td>
    ##   </tr>
    ## </tbody>
    ## </table>
    ##
    ## AUC/AUPRC
    ## AUC (ROC): 0.835290
    ## AUPRC: 0.766330
    ##
    ## ===== TEST =====
    ##
    ## Classification Report
    ## <table>
    ##  <thead>
    ##   <tr>
    ##    <th style="text-align:left;">   </th>
    ##    <th style="text-align:left;"> precision </th>
    ##    <th style="text-align:left;"> recall </th>
    ##    <th style="text-align:left;"> f1-score </th>
    ##    <th style="text-align:left;"> support </th>
    ##   </tr>
    ##  </thead>
    ## <tbody>
    ##   <tr>
    ##    <td style="text-align:left;"> 0 </td>
    ##    <td style="text-align:left;"> 0.859944 </td>
    ##    <td style="text-align:left;"> 0.579245 </td>
    ##    <td style="text-align:left;"> 0.692221 </td>
    ##    <td style="text-align:left;"> 530.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> 1 </td>
    ##    <td style="text-align:left;"> 0.432570 </td>
    ##    <td style="text-align:left;"> 0.772727 </td>
    ##    <td style="text-align:left;"> 0.554649 </td>
    ##    <td style="text-align:left;"> 220.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> accuracy </td>
    ##    <td style="text-align:left;"> 0.636000 </td>
    ##    <td style="text-align:left;"> 0.636000 </td>
    ##    <td style="text-align:left;"> 0.636000 </td>
    ##    <td style="text-align:left;"> 750.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> macro avg </td>
    ##    <td style="text-align:left;"> 0.646257 </td>
    ##    <td style="text-align:left;"> 0.675986 </td>
    ##    <td style="text-align:left;"> 0.623435 </td>
    ##    <td style="text-align:left;"> 750.000000 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> weighted avg </td>
    ##    <td style="text-align:left;"> 0.734581 </td>
    ##    <td style="text-align:left;"> 0.636000 </td>
    ##    <td style="text-align:left;"> 0.651867 </td>
    ##    <td style="text-align:left;"> 750.000000 </td>
    ##   </tr>
    ## </tbody>
    ## </table>
    ##
    ## Confusion Matrix
    ## <table>
    ##  <thead>
    ##   <tr>
    ##    <th style="text-align:left;">   </th>
    ##    <th style="text-align:right;"> Positive (1) </th>
    ##    <th style="text-align:right;"> Negative (0) </th>
    ##   </tr>
    ##  </thead>
    ## <tbody>
    ##   <tr>
    ##    <td style="text-align:left;"> Positive (1) </td>
    ##    <td style="text-align:right;"> 170 </td>
    ##    <td style="text-align:right;"> 223 </td>
    ##   </tr>
    ##   <tr>
    ##    <td style="text-align:left;"> Negative (0) </td>
    ##    <td style="text-align:right;"> 50 </td>
    ##    <td style="text-align:right;"> 307 </td>
    ##   </tr>
    ## </tbody>
    ## </table>
    ##
    ## AUC/AUPRC
    ## AUC (ROC): 0.781407
    ## AUPRC: 0.654612

## Scenario 2 — Saved plots