Skip to contents

Saves an impute_result to a directory. R-native fields are written to an RDS file. The CISSVAE PyTorch model, if present, is saved separately as a state_dict checkpoint (.pt) so that the live Python object is never passed to saveRDS (which cannot serialise it). The model architecture is captured automatically from the live object and stored inside the RDS so that load_impute_result can reconstruct it without any additional input from the user.

Usage

save_impute_result(x, dir, name = "result", overwrite = FALSE)

Arguments

x

An object of class impute_result.

dir

Character string. Path to the directory in which to write files. Created recursively if it does not exist.

name

Character string. Base name used for output files. Defaults to "result". Two files are written:

  • <name>.rds — R data (all fields except the live model).

  • <name>_state_dict.pt — PyTorch model weights.

overwrite

Logical. If FALSE (default), an error is raised when output files already exist. Set to TRUE to overwrite silently.

Value

Invisibly, a named list with elements meta (path to the RDS) and model (path to the .pt file, or NULL if no model was present).

Examples

if (FALSE) { # \dontrun{
res <- ciss_vae(data = my_data, return_model = TRUE, ...)
save_impute_result(res, dir = "run_001", name = "imputation_result")
} # }