loadGPModel: Load a 'GPModel' from a file

Description Usage Arguments Value Author(s) Examples

View source: R/GPModel.R

Description

Load a GPModel from a file

Usage

1
loadGPModel(filename)

Arguments

filename

filename for loading

Value

A GPModel

Author(s)

Fabio Sigrist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(gpboost)
data(GPBoost_data, package = "gpboost")

gp_model <- fitGPModel(group_data = group_data[,1], y = y, likelihood="gaussian")
pred <- predict(gp_model, group_data_pred = group_data_test[,1], predict_var = TRUE)
# Save model to file
filename <- tempfile(fileext = ".json")
saveGPModel(gp_model,filename = filename)
# Load from file and make predictions again
gp_model_loaded <- loadGPModel(filename = filename)
pred_loaded <- predict(gp_model_loaded, group_data_pred = group_data_test[,1], predict_var = TRUE)
# Check equality
pred$mu - pred_loaded$mu
pred$var - pred_loaded$var

gpboost documentation built on July 14, 2021, 9:06 a.m.