EnsemblePredictions {sharp}R Documentation

Predictions from ensemble model

Description

Makes predictions using an ensemble model created from VariableSelection outputs. For each observation in xdata, the predictions are calculated as the average predicted values obtained for that observation over the K models fitted in calibrated stability selection.

Usage

EnsemblePredictions(ensemble, xdata, ...)

Arguments

ensemble

output of Ensemble.

xdata

matrix of predictors with observations as rows and variables as columns.

...

additional parameters passed to predict.

Value

A matrix of predictions computed from the observations in xdata.

See Also

predict.variable_selection

Other ensemble model functions: Ensemble()

Examples


# Data simulation
set.seed(1)
simul <- SimulateRegression(n = 1000, pk = 50, family = "gaussian")

# Training/test split
ids <- Split(data = simul$ydata, tau = c(0.8, 0.2))
stab <- VariableSelection(
  xdata = simul$xdata[ids[[1]], ],
  ydata = simul$ydata[ids[[1]], ]
)

# Constructing the ensemble model
ensemble <- Ensemble(
  stability = stab,
  xdata = simul$xdata[ids[[1]], ],
  ydata = simul$ydata[ids[[1]], ]
)

# Making predictions
yhat <- EnsemblePredictions(
  ensemble = ensemble,
  xdata = simul$xdata[ids[[2]], ]
)

# Calculating Q-squared
cor(simul$ydata[ids[[2]], ], yhat)^2


[Package sharp version 1.4.6 Index]