src.plot.torf_rfvsnn_plot

Classes

TorfRFvsNNPlot(**kwargs)

class src.plot.torf_rfvsnn_plot.TorfRFvsNNPlot(**kwargs)
Author:

Alberto M. Esmoris Pena

Comparison plot of Random Forest (RF) vs Neural Network (NN) predictions, probabilities, and uncertainties for the TransfOctoRF pipeline.

Generates a multi-panel figure with:

  1. Per-class F1 comparison — grouped bar chart showing RF and NN F1 scores side by side for each class.

  2. Class ambiguity distributions — overlapping histograms of RF and NN class ambiguity values.

  3. Prediction agreement — pie chart showing the fraction of samples where RF and NN agree vs disagree.

  4. Ambiguity scatter — scatter plot of RF ambiguity (x) vs NN ambiguity (y) per sample, colored by agreement.

Variables:
  • rf_proba (np.ndarray) – RF pseudoprobabilities (S, n_c).

  • nn_proba (np.ndarray) – NN probabilities (S, n_c).

  • y_true (np.ndarray) – Ground-truth labels (S,).

  • class_names (list or None) – Optional class names for axis labels.

__init__(**kwargs)

Initialize a TorfRFvsNNPlot.

Parameters:

kwargs – Plot attributes including data arrays.

plot(**kwargs)

Generate the 4-panel RF vs NN comparison figure.

See plot.Plot.plot().

plot_f1_comparison(ax)

Grouped bar chart of per-class F1 scores.

Parameters:

ax – Matplotlib axes.

plot_ambiguity_histograms(ax)

Overlapping histograms of class ambiguity.

Parameters:

ax – Matplotlib axes.

plot_agreement_pie(ax)

Pie chart of RF-NN prediction agreement.

Parameters:

ax – Matplotlib axes.

plot_ambiguity_scatter(ax)

Scatter plot of RF vs NN ambiguity per sample.

Parameters:

ax – Matplotlib axes.

static class_ambiguity(proba)

Compute class ambiguity from a probability matrix.

\(a = 1 - p_{\text{max}} + p_{\text{second}}\)

Parameters:

proba – Probability matrix (S, n_c).

Returns:

Ambiguity array (S,).