% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sensitivity-analysis.R
\name{classification_robustness}
\alias{classification_robustness}
\title{Robustness of classification under input perturbation}
\usage{
classification_robustness(
  pedon,
  system = c("wrb2022", "sibcs", "usda"),
  level = c("order", "name"),
  n = 50L,
  perturbations = NULL,
  provenance_aware = FALSE,
  seed = 42L
)
}
\arguments{
\item{pedon}{A \code{\link{PedonRecord}}.}

\item{system}{One of \code{"wrb2022"}, \code{"sibcs"}, \code{"usda"}.}

\item{level}{Either \code{"order"} (compare \code{$rsg_or_order})
or \code{"name"} (compare full classification name).}

\item{n}{Number of Monte-Carlo perturbed runs (default 50).}

\item{perturbations}{Named list. Each name is a horizon column;
each element is a function taking the original value and
returning a perturbed value. NA-tolerant. Ignored when
\code{provenance_aware = TRUE}.}

\item{provenance_aware}{If \code{FALSE} (default) every cell is
perturbed by the fixed \code{perturbations} panel -- the exact
v0.9.42 behaviour. If \code{TRUE}, each \code{(horizon,
attribute)} cell is perturbed by an amount scaled to its
provenance evidence grade, and \code{perturbations} is
ignored. See \code{\link{classify_with_uncertainty}} for the
full provenance-weighted posterior.}

\item{seed}{Random seed for reproducibility.}
}
\value{
A list with elements \code{baseline} (the unperturbed
        classification name), \code{n} (number of MC runs),
        \code{robustness} (fraction of perturbed runs matching
        baseline), \code{flipped_to} (table of alternative
        classifications when the perturbation flipped the result).
}
\description{
For a given \code{\link{PedonRecord}}, perturb a chosen list of
horizon attributes by a configured fractional amount, re-classify
under the requested system, and report how often the classification
\code{$rsg_or_order} (or full \code{$name}) matches the unperturbed
baseline.
}
\details{
Default perturbation panel:
\itemize{
  \item \code{clay_pct}: ±5 % of value
  \item \code{sand_pct}: ±5 % of value
  \item \code{silt_pct}: ±5 % of value
  \item \code{ph_h2o}: ±0.2 absolute
  \item \code{oc_pct}: ±10 % of value
}
}
\examples{
\dontrun{
p <- make_ferralsol_canonical()
classification_robustness(p, system = "wrb2022", n = 50)
#> $baseline    : "Ferralsols"
#> $robustness  : 0.96  (48 / 50 perturbed runs landed on Ferralsols)
#> $flipped_to  : table(c("Cambisols" = 1, "Acrisols" = 1))
}
}
