% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gpb.Booster.R
\name{gpb.load}
\alias{gpb.load}
\title{Load GPBoost model}
\usage{
gpb.load(filename = NULL, model_str = NULL)
}
\arguments{
\item{filename}{path of model file}

\item{model_str}{a str containing the model}
}
\value{
gpb.Booster
}
\description{
Load GPBoost takes in either a file path or model string.
              If both are provided, Load will default to loading from file
              Boosters with gp_models can only be loaded from file.
}
\examples{
\donttest{
library(gpboost)
data(GPBoost_data, package = "gpboost")

# Train model and make prediction
gp_model <- GPModel(group_data = group_data[,1], likelihood = "gaussian")
bst <- gpboost(data = X, label = y, gp_model = gp_model, nrounds = 16,
               learning_rate = 0.05, max_depth = 6, min_data_in_leaf = 5,
               verbose = 0)
pred <- predict(bst, data = X_test, group_data_pred = group_data_test[,1],
                predict_var= TRUE, pred_latent = TRUE)
# Save model to file
filename <- tempfile(fileext = ".json")
gpb.save(bst,filename = filename)
# Load from file and make predictions again
bst_loaded <- gpb.load(filename = filename)
pred_loaded <- predict(bst_loaded, data = X_test, group_data_pred = group_data_test[,1],
                       predict_var= TRUE, pred_latent = TRUE)
# Check equality
pred$fixed_effect - pred_loaded$fixed_effect
pred$random_effect_mean - pred_loaded$random_effect_mean
pred$random_effect_cov - pred_loaded$random_effect_cov
}
}
\author{
Fabio Sigrist, authors of the LightGBM R package
}
