predict.PIE {PIE}R Documentation

Make Predictions for PIE

Description

predicts the response of a PIE object using new data.

Usage

## S3 method for class 'PIE'
predict(object, X, X_orig, ...)

Arguments

object

A fitted PIE object.

X

A matrix for the dataset with features expanded using numerical splines.

X_orig

A matrix for the dataset with original features without numerical splines.

...

Not used. Other arguments to predict.

Details

Make Predictions for PIE

This function predicts the response of a PIE object.

The PIE_predict function use generate predictions on dataset given the coefficients of group lasso and coefficients for XGBoost Trees

Value

A list containing:

total

The predicted value of the whole model for given features

white_box

The contribution of group lasso for the given features

black_box

The contribution of XGBoost model for the given features

Examples


# Load the training data
data("winequality")

# Which columns are numerical?
num_col <- 1:11
# Which columns are categorical?
cat_col <- 12
# Which column is the response?
y_col <- ncol(winequality)

# Data Processing (the first 200 rows are sampled for demonstration)
dat <- data_process(X = as.matrix(winequality[1:200, -y_col]), 
  y = winequality[1:200, y_col], 
  num_col = num_col, cat_col = cat_col, y_col = y_col)

# Fit a PIE model
fold <- 1
fit <- PIE_fit(
  X = dat$spl_train_X[[fold]],
  y = dat$train_y[[fold]],
  lasso_group = dat$lasso_group,
  X_orig = dat$orig_train_X[[fold]],
  lambda1 = 0.01, lambda2 = 0.01, iter = 5, eta = 0.05, nrounds = 200
)

# Prediction
pred <- predict(fit, 
  X = dat$spl_validation_X[[fold]],
  X_orig = dat$orig_validation_X[[fold]]
)


[Package PIE version 1.0.0 Index]