% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/serialization.R
\name{ForestSamplesSerialization}
\alias{ForestSamplesSerialization}
\alias{loadForestContainerJson}
\alias{loadForestContainerCombinedJson}
\alias{loadForestContainerCombinedJsonString}
\title{Forest Container Serialization Routines}
\usage{
loadForestContainerJson(json_object, json_forest_label)

loadForestContainerCombinedJson(json_object_list, json_forest_label)

loadForestContainerCombinedJsonString(json_string_list, json_forest_label)
}
\arguments{
\item{json_object}{Object of class \code{CppJson}}

\item{json_forest_label}{Label referring to a particular forest (i.e. "forest_0") in the overall json hierarchy (must exist in every json object in a list if a list is provided)}

\item{json_object_list}{List of objects of class \code{CppJson}}

\item{json_string_list}{List of strings that parse into objects of type \code{CppJson}}
}
\value{
Each of the functions in this group returns a \code{ForestSamples} object.
}
\description{
While the \link{BARTSerialization} and \link{BCFSerialization} topics focus on JSON serialization / deserialization for
entire \code{bartmodel} and \code{bcfmodel} objects, this function group provides an interface for a more focused use case:
loading a single \link{ForestSamples} container from a broader BART / BCF model (which may include multiple forests and other parametric terms).

\code{loadForestContainerJson} converts a \link{CppJson} object representing a BART or BCF model into a \link{ForestSamples} container
by extracting the JSON indexed by a forest label (i.e. \code{"forest_0"}) and deserializing it into a \link{ForestSamples} object.

Both \code{loadForestContainerJson} and \code{loadForestContainerCombinedJson} operate similarly, but on a list of \link{CppJson} or JSON string
representations of BART / BCF models with the same structure.

These functions are intended for advanced use cases in which users require detailed control of sampling algorithms and data structures.
Minimal input validation and error checks are performed -- users are responsible for providing the correct inputs.
For tutorials on the "proper" usage of the stochtree's advanced workflow, we provide several vignettes at \url{https://stochtree.ai/}
}
\examples{
X <- matrix(runif(10*100), ncol = 10)
y <- -5 + 10*(X[,1] > 0.5) + rnorm(100)
bart_model <- bart(X, y, num_gfr=0, num_mcmc=10)
bart_json <- saveBARTModelToJson(bart_model)
bart_json_string <- saveBARTModelToJsonString(bart_model)
bart_json_list <- list(bart_json)
bart_json_string_list <- list(bart_json_string)
mean_forest <- loadForestContainerJson(bart_json, "forest_0")
mean_forest <- loadForestContainerCombinedJson(bart_json_list, "forest_0")
mean_forest <- loadForestContainerCombinedJsonString(bart_json_string_list, "forest_0")

}
