% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update_testset_R_C_M_K.R
\name{update_testset_R_C_M_K}
\alias{update_testset_R_C_M_K}
\title{Update Test Set Representations, Cluster Assignments, and Cluster Centers}
\usage{
update_testset_R_C_M_K(args, model, data_test, dataloader_test, data_train)
}
\arguments{
\item{args}{A list of arguments, typically containing configurations such as the number of hidden features (\code{n_hidden_fea}) and whether to use CUDA (\code{cuda}).}

\item{model}{A trained model, typically an autoencoder, that will be used to generate new representations for the test data.}

\item{data_test}{A list representing the test dataset. This list will be updated with new representations, cluster assignments, and cluster centers.}

\item{dataloader_test}{An object representing the test data loader, which provides batches of test data to the model.}

\item{data_train}{A list representing the training dataset, which contains reference cluster centers and other attributes needed for updating the test dataset.}
}
\value{
The function updates the following attributes within the \code{data_test} list:
\itemize{
\item \code{rep}: The new representations (embeddings) for the test dataset.
\item \code{n_cat}: The number of clusters, set to match the training dataset.
\item \code{M}: The cluster centers, copied from the training dataset.
\item \code{pred_C}: The predicted cluster assignments for each test sample, based on the updated representations and cluster centers.
}
}
\description{
This function updates the representations, cluster assignments, and cluster centers for a test dataset based on a trained model and a reference training dataset.
}
\details{
The \code{update_testset_R_C_M_K} function performs the following steps:
\enumerate{
\item Initializes a tensor, \code{final_embed}, to store the embeddings for the test dataset.
\item Sets the model to evaluation mode.
\item Iterates through the test data batches using \code{dataloader_test}, processing each batch through the model to obtain the embeddings.
\item Updates the \code{rep} attribute of \code{data_test} with the new embeddings.
\item Updates \code{data_test$n_cat} and \code{data_test$M} to match the training dataset.
\item For each test sample, computes the closest cluster center (based on Euclidean distance) and assigns the corresponding cluster to \code{pred_C}.
}
}
\examples{
\donttest{
## Called internally by DICEr() to assign test-set cluster labels.
## Requires a trained DICEr model and data objects; see ?DICEr.
}
}
