% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hnp_package.r
\name{hnp_summary}
\alias{hnp_summary}
\title{HNP Classifier's Performance Summary}
\usage{
hnp_summary(classifier, X, Y, importance_order = NULL)
}
\arguments{
\item{classifier}{Either a function \code{function(X) ...} returning class labels
or an \verb{n x T} score/probability matrix, or a fitted model object (e.g.
randomForest, support vector machine, multinomial logistic regression) from which predictions can be derived.}

\item{X}{A data.frame of features (or a score matrix) to predict on.}

\item{Y}{A vector of true class labels of length \code{nrow(X)}.}

\item{importance_order}{Optional character vector giving the class priority
order (most severe first). If \code{NULL}, the order is taken from the
classifier's attributes or inferred from \code{Y}.}
}
\value{
A list with components of the HNP experiment results including \code{confusion_matrix},
\code{false_positive_rate}, \code{false_negative_rate}, \code{overall_accuracy},
\code{predictions}, \code{predictions_sample}, \code{under_classification_error},
\code{over_classification_error}, \code{total_under_classification_error},
\code{total_over_classification_error}, \code{error_table}, \code{class_levels},
\code{internal_levels}, \code{label_mapping}, \code{importance_order}, and \code{order_source}.
}
\description{
Evaluate a \code{T}-class classifier produced by
the HNP pipeline (or any compatible model/function). Given features and
true labels, it computes the confusion matrix, class-wise false
positive/negative rates, under- and over-classification errors, overall
accuracy, and a row-normalized error table. The class priority order is
resolved from \code{importance_order}, from attributes attached to the
\code{classifier}, or inferred from the labels.
}
\examples{
set.seed(123)
n <- 300
X <- data.frame(x1 = rnorm(n), x2 = rnorm(n))
Y <- sample(c("A", "B", "C"), n, replace = TRUE)
clf <- hnp_umbrella(
  X = X, Y = Y,
  levels = c(0.1, 0.1),
  tolerances = c(0.1, 0.1),
  importance_order = c("A", "B", "C"),
  method = "logistic"
)
result <- hnp_summary(clf, X = X, Y = Y, importance_order = c("A", "B", "C"))
}
\references{
Lijia Wang, Y. X. Rachel Wang, Jingyi Jessica Li, and Xin Tong (2024).
"Hierarchical Neyman-Pearson Classification for Prioritizing Severe Disease
Categories in COVID-19 Patient Data."
\emph{Journal of the American Statistical Association}, 119(545), 39-51.
\doi{10.1080/01621459.2023.2270657}
}
