Learn R Programming

xspliner (version 0.0.4)

xspline: Builds predictive model based GLM.

Description

The method provides main functionality on building GLM models with automatic variables transformation. The transformations are based on specified single variable responses for selected black-box model. See details in vignette("xspliner").

Usage

xspline(object, ...)

model_surrogate_xspliner(object, ...)

# S3 method for default xspline(object, lhs = NULL, response = NULL, predictors = NULL, data = NULL, form = "additive", bare = NULL, env = parent.frame(), ...)

# S3 method for formula xspline(object, model, data = NULL, consider = "specials", env = parent.frame(), ...)

# S3 method for explainer xspline(object, env = parent.frame(), ...)

Arguments

object

Predictive model, formula or explainer (see DALEX) object.

...

Other arguments passed to xspline methods or build_xspliner.

lhs

Left-hand side of model formula. Can be transformed response.

response

Name of response variable of model.

predictors

Predictor values that should be used in final model.

data

Training data of model.

form

Can be 'additive' (default) or 'multiplicative'. Specifies formula form in final model.

bare

Variable names that mustn't be transformed in final model.

env

Environment in which optional variables passed into parameters are stored. variables transformation. See vignette("xspliner") for details.

model

When object is formula - predictive model. Basic model used for extracting predictors transformation.

consider

One of c("specials", "all"). If "specials", only components with xs or xf call are considered in transition.

Value

GLM object of class 'xspliner'.

Details

model_surrogate_xspliner is a wrapper of xspline method to assure consistency with https://github.com/ModelOriented/DrWhy tools

Examples

Run this code
# NOT RUN {
# preparing blackbox model
library(randomForest)
rf_iris <- randomForest(
  Petal.Width ~  Sepal.Length + Petal.Length + Species,
  data = iris)

# formula based xspliner
xs_iris <- xspline(
  Petal.Width ~ xs(Sepal.Length) + xs(Petal.Length) + xf(Species),
  model = rf_iris)
summary(xs_iris)
plot(xs_iris, "Sepal.Length")

# passing just the model
xs_iris <- xspline(rf_iris)
summary(xs_iris)
plot(xs_iris, "Sepal.Length")

# using DALEX
library(DALEX)
xs_iris_explainer <- explain(rf_iris)
xs_iris <- xspline(rf_iris)
summary(xs_iris)
plot(xs_iris, "Sepal.Length")

# }

Run the code above in your browser using DataLab