`pdpZen.Rd`

Constructs a zigzag expanded navigation plot (zenplot) displaying partial dependence values.

pdpZen( data, fit, response, zpath = NULL, pal = rev(RColorBrewer::brewer.pal(11, "RdYlBu")), fitlims = "pdp", gridSize = 10, nmax = 500, class = 1, comboImage = FALSE, rug = TRUE, predictFun = NULL, convexHull = FALSE, probability = FALSE, ... )

data | Data frame used for fit |
---|---|

fit | A supervised machine learning model, which understands condvis2::CVpredict |

response | The name of the response for the fit |

zpath | Plot shows consecutive pairs of these variables. Defaults to all variables other than response.
Recommend constructing zpath witn |

pal | A vector of colors to show predictions, for use with scale_fill_gradientn |

fitlims | Specifies the fit range for the color map. Options are a numeric vector of length 2, "pdp" (default), in which cases limits are calculated from the pdp, or "all", when limits are calculated from the observations and pdp predictions outside fitlims are squished on the color scale. |

gridSize | The size of the grid for evaluating the predictions. |

nmax | Uses sample of nmax data rows for the pdp. Default is 500. Use all rows if NULL. |

class | Category for classification, a factor level, or a number indicating which factor level. |

comboImage | If TRUE draws pdp for mixed variable plots as an image, otherwise an interaction plot. |

rug | If TRUE adds rugs for the data to the pdp plots |

predictFun | Function of (fit, data) to extract numeric predictions from fit. Uses condvis2::CVpredict by default, which works for many fit classes. |

convexHull | If TRUE, then the convex hull is computed and any points outside the convex hull are removed. |

probability | if TRUE, then returns the partial dependence for classification on the probability scale. If FALSE (default), then the partial dependence is returned on a near logit scale. |

... | passed on to zenplot |

A zenplot of partial dependence values.

if (FALSE) { # To use this function, install zenplots and graph from Bioconductor. if (!requireNamespace("graph", quietly = TRUE)) { install.packages("BiocManager") BiocManager::install("graph") } install.packages("zenplots") library(MASS) library(ranger) Boston1 <- Boston Boston1$chas <- factor(Boston1$chas) rf <- ranger(medv ~ ., data = Boston1) pdpZen(Boston1[1:30, ], rf, response = "medv", zpath = names(Boston1)[1:4], comboImage = T) # Find the top variables in rf set.seed(123) viv <- vivi(Boston1, rf, "medv", nmax = 30) # use 30 rows, for speed pdpZen(Boston1, rf, response = "medv", zpath = rownames(viv)[1:4], comboImage = T) zpath <- zPath(viv, cutoff = .2) # find plots whose interaction score exceeds .2 pdpZen(Boston1, rf, response = "medv", zpath = zpath, comboImage = T) }