@@ -58,17 +58,17 @@ head(pd)
5858By default
5959[ ` partial() ` ] ( https://bgreenwell.github.io/pdp/reference/partial.md )
6060returns a data frame, which makes it easy to plot with whatever graphics
61- package you prefer. ** pdp** ships with two plotting options:
62-
63- - [ ` plot() ` ] ( https://rdrr.io/r/graphics/plot.default.html ) — lightweight
64- base R graphics via [ tinyplot] ( https://grantmcdermott.com/tinyplot/ ) ;
65- - [ ` plotPartial() ` ] ( https://bgreenwell.github.io/pdp/reference/plotPartial.md )
66- — [ lattice] ( https://cran.r-project.org/package=lattice ) graphics.
61+ package you prefer. ** pdp** ships with a
62+ [ ` plot() ` ] ( https://rdrr.io/r/graphics/plot.default.html ) method that
63+ draws lightweight base R graphics via
64+ [ tinyplot] ( https://grantmcdermott.com/tinyplot/ ) by default, or
65+ [ lattice ] ( https://cran.r-project.org/package=lattice ) graphics whenever
66+ ` lattice = TRUE ` :
6767
6868``` r
6969
70- # tinyplot-based plot() method ; rug marks show the min/max and deciles of
71- # lstat to help avoid interpreting the plot where there's little data
70+ # tinyplot-based display ; rug marks show the min/max and deciles of lstat to
71+ # help avoid interpreting the plot where there's little data
7272plot(pd , rug = TRUE , train = boston )
7373```
7474
@@ -77,10 +77,10 @@ plot(pd, rug = TRUE, train = boston)
7777``` r
7878
7979# lattice-based equivalent
80- plotPartial (pd , rug = TRUE , train = boston )
80+ plot (pd , rug = TRUE , train = boston , lattice = TRUE )
8181```
8282
83- ![ ] ( pdp_files/figure-html/boston-plotPartial -1.png )
83+ ![ ] ( pdp_files/figure-html/boston-plot-lattice -1.png )
8484
8585You can also let
8686[ ` partial() ` ] ( https://bgreenwell.github.io/pdp/reference/partial.md )
@@ -106,6 +106,33 @@ training values of `lstat` and `rm`, which reduces the risk of
106106extrapolating outside the region of the data. Factor predictors are
107107handled automatically and result in faceted displays.
108108
109+ ## 3-D surfaces and three predictors (lattice)
110+
111+ The lattice engine (` lattice = TRUE ` ) additionally supports 3-D surfaces
112+ and paneled three-predictor displays, like the figures in the [ R Journal
113+ paper] ( https://journal.r-project.org/articles/RJ-2017-016/ ) :
114+
115+ ``` r
116+
117+ # 3-D surface instead of a false color level plot
118+ plot(pd2 , lattice = TRUE , levelplot = FALSE , zlab = " cmedv" , drape = TRUE ,
119+ colorkey = FALSE , screen = list (z = - 20 , x = - 60 ))
120+ ```
121+
122+ ![ ] ( pdp_files/figure-html/boston-wireframe-1.png )
123+
124+ ``` r
125+
126+ # Three predictors: the third is binned into overlapping intervals and used
127+ # to panel the display (see the `number` and `overlap` arguments)
128+ pd3 <- partial(boston.rf , pred.var = c(" lstat" , " rm" , " age" ),
129+ grid.resolution = 10 , chull = TRUE , batch.size = 1e6 ,
130+ train = boston )
131+ plot(pd3 , lattice = TRUE )
132+ ```
133+
134+ ![ ] ( pdp_files/figure-html/boston-three-1.png )
135+
109136## Classification
110137
111138For classification models, partial dependence is computed for the
0 commit comments