Description Usage Arguments Value References See Also Examples

Calculates the partial dependence of the response on an arbitrary dimensional set of predictors from a fitted random forest object from the party, randomForest, randomForestSRC, or ranger packages

1 | ```
partial_dependence(fit, vars, n, interaction, uniform, data, ...)
``` |

`fit` |
object of class 'RandomForest', 'randomForest', 'rfsrc', or 'ranger' |

`vars` |
a character vector of the predictors of interest |

`n` |
two dimensional integer vector giving the resolution of the grid. the first element gives the grid on |

`interaction` |
logical, if 'vars' is a vector, does this specify an interaction or a list of bivariate partial dependence |

`uniform` |
logical, indicates whether a uniform or random grid is to be construct partial dependence calculation |

`data` |
the data.frame used to fit the model, only needed for 'randomForest' |

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

a data.frame with the partial dependence of 'vars' if 'vars' has length = 1 then the output will be a data.frame with a column for the predicted value at each value of 'vars', averaged over the values of all other predictors. if 'vars' has length > 1 and interaction is true or false then the output will be a data.frame with a column for each element of 'vars' and the predicted value for each combination.

Friedman, Jerome H. "Greedy function approximation: a gradient boosting machine." Annals of statistics (2001): 1189-1232.

`plot_pd`

for plotting `partial_dependence`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
library(randomForest)
library(edarf)
data(iris)
data(swiss)
## classification
fit = randomForest(Species ~ ., iris)
pd = partial_dependence(fit, c("Sepal.Width", "Sepal.Length"),
data = iris[, -ncol(iris)])
pd_int = partial_dependence(fit, c("Petal.Width", "Sepal.Length"),
interaction = TRUE, data = iris[, -ncol(iris)])
## Regression
fit = randomForest(Fertility ~ ., swiss)
pd = partial_dependence(fit, c("Education", "Examination"), data = swiss[, -1])
pd_int = partial_dependence(fit, c("Education", "Examination"),
interaction = TRUE, data = swiss[, -1])
``` |

```
randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.
```

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.