Description Usage Arguments Value References See Also Examples

View source: R/generatePartialDependence.R

Estimate how the learned prediction function is affected by one or more features. For a learned function f(x) where x is partitioned into x_s and x_c, the partial dependence of f on x_s can be summarized by averaging over x_c and setting x_s to a range of values of interest, estimating E_(x_c)(f(x_s, x_c)). The conditional expectation of f at observation i is estimated similarly. Additionally, partial derivatives of the marginalized function w.r.t. the features can be computed.

1 2 3 4 |

`obj` |
[ |

`input` |
[ |

`features` |
[ |

`interaction` |
[ |

`derivative` |
[ |

`individual` |
[ |

`center` |
[ |

`fun` |
[ |

`bounds` |
[ |

`resample` |
[ |

`fmin` |
[ |

`fmax` |
[ |

`gridsize` |
[ |

`range` |
[ |

`...` |
additional arguments to be passed to |

[`PartialDependenceData`

]. A named list, which contains the partial dependence,
input data, target, features, task description, and other arguments controlling the type of
partial dependences made.

Object members:

`data` |
[ |

`task.desc` |
[ |

`target` |
Target feature for regression, target feature levels for classification, survival and event indicator for survival. |

`features` |
[ |

`interaction` |
[ |

`derivative` |
[ |

`individual` |
[ |

`center` |
[ |

Goldstein, Alex, Adam Kapelner, Justin Bleich, and Emil Pitkin. “Peeking inside the black box: Visualizing statistical learning with plots of individual conditional expectation.” Journal of Computational and Graphical Statistics. Vol. 24, No. 1 (2015): 44-65.

Friedman, Jerome. “Greedy Function Approximation: A Gradient Boosting Machine.” The Annals of Statistics. Vol. 29. No. 5 (2001): 1189-1232.

Other partial_dependence: `plotPartialDependenceGGVIS`

,
`plotPartialDependence`

Other generate_plot_data: `generateCalibrationData`

,
`generateCritDifferencesData`

,
`generateFeatureImportanceData`

,
`generateFilterValuesData`

,
`generateFunctionalANOVAData`

,
`generateLearningCurveData`

,
`generateThreshVsPerfData`

,
`getFilterValues`

,
`plotFilterValues`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ```
lrn = makeLearner("regr.svm")
fit = train(lrn, bh.task)
pd = generatePartialDependenceData(fit, bh.task, "lstat")
plotPartialDependence(pd, data = getTaskData(bh.task))
lrn = makeLearner("classif.rpart", predict.type = "prob")
fit = train(lrn, iris.task)
pd = generatePartialDependenceData(fit, iris.task, "Petal.Width")
plotPartialDependence(pd, data = getTaskData(iris.task))
# simulated example with weights computed via the joint distribution
# in practice empirical weights could be constructed by estimating the joint
# density from the training data (the data arg to fun) and computing the probability
# of the prediction grid under this estimated density (the newdata arg) or
# by using something like data depth or outlier classification to weight the
# unusualness of points in arg newdata.
sigma = matrix(c(1, .5, .5, 1), 2, 2)
C = chol(sigma)
X = replicate(2, rnorm(100)) %*% C
alpha = runif(2, -1, 1)
y = X %*% alpha
df = data.frame(y, X)
tsk = makeRegrTask(data = df, target = "y")
fit = train("regr.svm", tsk)
w.fun = function(x, newdata) {
# compute multivariate normal density given sigma
sigma = matrix(c(1, .5, .5, 1), 2, 2)
dec = chol(sigma)
tmp = backsolve(dec, t(newdata), transpose = TRUE)
rss = colSums(tmp^2)
logretval = -sum(log(diag(dec))) - 0.5 * ncol(newdata) * log(2 * pi) - 0.5 * rss
w = exp(logretval)
# weight prediction grid given probability of grid points under the joint
# density
sum(w * x) / sum(w)
}
generatePartialDependenceData(fit, tsk, "X1", fun = w.fun)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.