% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/func_analysis_test_error_D0406.R
\name{func_analysis_test_error_D0406}
\alias{func_analysis_test_error_D0406}
\title{Analyze Test Error and Performance Metrics for a Model}
\usage{
func_analysis_test_error_D0406(args, model, data_test, dataloader_test)
}
\arguments{
\item{args}{A list of arguments, typically containing configurations such as whether to use CUDA for computation.}

\item{model}{A trained model that will be evaluated. The model should have a \code{forward} method that supports an "outcome_logistic_regression" mode.}

\item{data_test}{A list representing the test dataset. This list will be updated with predicted cluster assignments.}

\item{dataloader_test}{An object representing the test data loader, which provides batches of test data to the model.}
}
\value{
A list containing the following performance metrics:
\itemize{
\item \code{test_AE_loss}: The mean autoencoder loss (MSE) across all batches in the test dataset.
\item \code{test_classifier_c_accuracy}: The classification accuracy of the model in predicting cluster assignments.
\item \code{test_outcome_likelihood}: The mean binary cross-entropy loss for the outcome prediction.
\item \code{outcome_auc_score}: The AUC (Area Under the Curve) score for the outcome prediction, which measures the model's ability to distinguish between positive and negative classes.
}
}
\description{
This function evaluates a trained model on a test dataset, calculating various performance metrics including autoencoder loss, outcome likelihood, classification accuracy, and AUC score for outcome prediction.
}
\details{
The \code{func_analysis_test_error_D0406} function performs the following steps:
\enumerate{
\item Sets the model to evaluation mode to ensure proper handling of layers like dropout.
\item Iterates over the test data batches provided by \code{dataloader_test}.
\item For each batch, it performs a forward pass through the model using the "outcome_logistic_regression" mode, obtaining the encoded representations, decoded outputs, raw cluster predictions, and outcome predictions.
\item Computes the mean squared error (MSE) for the autoencoder loss, binary cross-entropy (BCE) for the outcome prediction loss, and classification accuracy for cluster prediction.
\item Accumulates the true outcomes and predicted probabilities for calculating the AUC score.
\item Updates the \code{data_test} list with the predicted cluster assignments.
\item Returns the average values of the computed metrics across all test batches.
}
}
\examples{
\donttest{
## Called internally by DICEr() to evaluate the held-out test set.
## Requires a trained DICEr model object; see ?DICEr for a full example.
}
}
