epdiff: Explain difference between predictions from a model

Description Usage Arguments Value Examples

View source: R/epdiff.R

Description

Explain difference between predictions from a model

Usage

1
epdiff(mod, x1, x2, d, predictfunc)

Arguments

mod

Model

x1

Input 1. Single row data frame or matrix.

x2

Input 2. Single row data frame or matrix.

d

Max number of input dimensions to use.

predictfunc

Func to use to predict. Defaults to 'predict'.

Value

ggplot object showing effect

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# gbm
m1 <- gbm::gbm(Petal.Width ~ Sepal.Length + Sepal.Width, data=iris, distribution='gaussian')
x1 <- iris[1,]
x2 <- iris[2,]
epdiff(m1, x1, x2)
epdiff(m1, iris[12,], iris[20,])
epdiff(m1, iris[sample(1:nrow(iris), 1),], iris[sample(1:nrow(iris), 1),])

# Linear model
mod_lm <- lm(Petal.Width ~ Sepal.Length + Sepal.Width, data=iris)
epdiff(mod_lm, iris[sample(1:nrow(iris), 1),], iris[sample(1:nrow(iris), 1),])
epdiff(mod_lm, iris[sample(1:nrow(iris), 1),], iris[sample(1:nrow(iris), 1),], d=3)
mod_lm2 <- lm(Petal.Width ~ Petal.Length + Sepal.Width, data=iris)
epdiff(mod_lm2, iris[sample(1:nrow(iris), 1),], iris[sample(1:nrow(iris), 1),])

CollinErickson/ExplainPrediction2 documentation built on Dec. 17, 2021, 3:02 p.m.