Skip to content

Diagnostics API

ModelDiagnostics

ModelDiagnostics

Diagnostic suite to verify the well-posedness and numerical stability of the CancerRLTOModel.

plot_component_decomposition

plot_component_decomposition(
    gene_name: str,
    n_points: int = 100,
    n_samples: int = 5000,
)
  1. Proves well-posedness by showing the internal trade-off components.

plot_noise_stability

plot_noise_stability(
    gene_name: str,
    n_evals: int = 10,
    grid_points: int = 40,
    n_samples: int = 5000,
)
  1. Checks if Monte Carlo noise overwhelms the peak curvature.

plot_convergence_check

plot_convergence_check(
    gene_name: str,
    n_trials: int = 20,
    n_samples: int = 3000,
)
  1. Verifies the optimizer finds the same peak regardless of starting guess.

plot_bivariate_landscape

plot_bivariate_landscape(
    gene1_name: str,
    gene2_name: str,
    grid_size: int = 40,
    n_samples: int = 0,
)
  1. Checks for infinite ridges or compensation in the 2D global landscape.

plot_sensitivity_profile

plot_sensitivity_profile(
    gene_name: str,
    param_name: str = "toxicity_global",
    n_steps: int = 15,
)
  1. Ensures smooth responses to parameter perturbations (no brittle cliffs).

example_usage

example_usage

example_usage() -> Dict[str, object]

Diagnostics guide

The plotting methods are intended to answer different questions:

Method Intended diagnostic question
plot_component_decomposition() do robustness, burden, toxicity, and net fitness produce a well-shaped objective?
plot_noise_stability() how sensitive is the local objective region around the optimum?
plot_convergence_check() does optimization converge from varied starting points?
plot_bivariate_landscape() does the joint landscape show compensation ridges or a clear optimum?
plot_sensitivity_profile() does the optimum move smoothly under parameter perturbation?

Saving plots

from rlto_model import ModelDiagnostics

diag = ModelDiagnostics(model)
fig = diag.plot_bivariate_landscape("MYC", "KRAS")
fig.savefig("bivariate_MYC_KRAS.png")

Operational note

The example script closes figures after saving them. That pattern is worth preserving in batch runs to avoid figure accumulation.