R/createSpatialResamplingPlots.R
Visualize partitioning of resample objects with spatial information.
createSpatialResamplingPlots(task = NULL, resample = NULL, crs = NULL, datum = 4326, repetitions = 1, color.train = "#0072B5", color.test = "#E18727", point.size = 0.5, axis.text.size = 14, x.axis.breaks = waiver(), y.axis.breaks = waiver())
| task | Task |
|---|---|
| resample | ResampleResult or named |
| crs | integer |
| datum | integer |
| repetitions | integer |
| color.train | Color for train set. |
| color.test | Color for test set. |
| point.size | Point size. |
| axis.text.size | Font size of axis labels. |
(list of 2L containing (1) multiple `gg`` objects and (2) their
corresponding labels.
If a named list is given to resample, names will appear in the title of
each fold.
If multiple inputs are given to resample, these must be named.
This function makes a hard cut at five columns of the resulting gridded plot.
This means if the resample object consists of folds > 5, these folds will
be put into the new row.
For file saving, we recommend to use cowplot::save_plot.
When viewing the resulting plot in RStudio, margins may appear to be different than they really are. Make sure to save the file to disk and inspect the image.
When modifying axis breaks, negative values need to be used if the area is located in either the western or southern hemisphere. Use positive values for the northern and eastern hemisphere.
The crs has to be suitable for the coordinates stored in the Task.
For example, if the coordinates are UTM, crs should be set to a
UTM projection.
Due to a limited axis space in the resulting grid (especially on the x-axis),
the data will by default projected into a lat/lon projection, specifically
EPSG 4326.
If other projections are desired for the resulting map, please set argument
datum accordingly. This argument will be passed onto sf::coord_sf.
Other plot: plotBMRBoxplots,
plotBMRRanksAsBarChart,
plotBMRSummary,
plotCalibration,
plotCritDifferences,
plotLearningCurve,
plotPartialDependence,
plotROCCurves, plotResiduals,
plotThreshVsPerf
rdesc = makeResampleDesc("SpRepCV", folds = 5, reps = 4) r = resample(makeLearner("classif.qda"), spatial.task, rdesc) ##------------------------------------------------------------- ## single unnamed resample input with 5 folds and 2 repetitions ##------------------------------------------------------------- plots = createSpatialResamplingPlots(spatial.task, r, crs = 32717, repetitions = 2, x.axis.breaks = c(-79.065, -79.085), y.axis.breaks = c(-3.970, -4))#> Error in createSpatialResamplingPlots(spatial.task, r, crs = 32717, repetitions = 2, x.axis.breaks = c(-79.065, -79.085), y.axis.breaks = c(-3.97, -4)): could not find function "createSpatialResamplingPlots"plot_grid(plotlist = plots[["Plots"]], ncol = 5, nrow = 2, labels = plots[["Labels"]])#> Error in plot_grid(plotlist = plots[["Plots"]], ncol = 5, nrow = 2, labels = plots[["Labels"]]): could not find function "plot_grid"##-------------------------------------------------------------------------- ## single named resample input with 5 folds and 1 repetition and 32717 datum ##-------------------------------------------------------------------------- plots = createSpatialResamplingPlots(spatial.task, list("Resamp" = r), crs = 32717, datum = 32717, repetitions = 1)#> Error in createSpatialResamplingPlots(spatial.task, list(Resamp = r), crs = 32717, datum = 32717, repetitions = 1): could not find function "createSpatialResamplingPlots"plot_grid(plotlist = plots[["Plots"]], ncol = 5, nrow = 1, labels = plots[["Labels"]])#> Error in plot_grid(plotlist = plots[["Plots"]], ncol = 5, nrow = 1, labels = plots[["Labels"]]): could not find function "plot_grid"##------------------------------------------------------------- ## multiple named resample inputs with 5 folds and 1 repetition ##------------------------------------------------------------- rdesc1 = makeResampleDesc("SpRepCV", folds = 5, reps = 4) r1 = resample(makeLearner("classif.qda"), spatial.task, rdesc1) rdesc2 = makeResampleDesc("RepCV", folds = 5, reps = 4) r2 = resample(makeLearner("classif.qda"), spatial.task, rdesc2) plots = createSpatialResamplingPlots(spatial.task, list("SpRepCV" = r1, "RepCV" = r2), crs = 32717, repetitions = 1, x.axis.breaks = c(-79.055, -79.085), y.axis.breaks = c(-3.975, -4))#> Error in createSpatialResamplingPlots(spatial.task, list(SpRepCV = r1, RepCV = r2), crs = 32717, repetitions = 1, x.axis.breaks = c(-79.055, -79.085), y.axis.breaks = c(-3.975, -4)): could not find function "createSpatialResamplingPlots"plot_grid(plotlist = plots[["Plots"]], ncol = 5, nrow = 2, labels = plots[["Labels"]])#> Error in plot_grid(plotlist = plots[["Plots"]], ncol = 5, nrow = 2, labels = plots[["Labels"]]): could not find function "plot_grid"##------------------------------------------------------------------------------------- ## Complex arrangements of multiple named resample inputs with 5 folds and 1 repetition ##------------------------------------------------------------------------------------- p1 <- plot_grid(plist[["Plots"]][[1]], plist[["Plots"]][[2]], plist[["Plots"]][[3]], ncol = 3, nrow = 1, labels = plist[["Labels"]][1:3], label_size = 18)#> Error in plot_grid(plist[["Plots"]][[1]], plist[["Plots"]][[2]], plist[["Plots"]][[3]], ncol = 3, nrow = 1, labels = plist[["Labels"]][1:3], label_size = 18): could not find function "plot_grid"p12 <- plot_grid(plist[["Plots"]][[4]], plist[["Plots"]][[5]], ncol = 2, nrow = 1, labels = plist[["Labels"]][4:5], label_size = 18)#> Error in plot_grid(plist[["Plots"]][[4]], plist[["Plots"]][[5]], ncol = 2, nrow = 1, labels = plist[["Labels"]][4:5], label_size = 18): could not find function "plot_grid"p2 <- plot_grid(plist[["Plots"]][[6]], plist[["Plots"]][[7]], plist[["Plots"]][[8]], ncol = 3, nrow = 1, labels = plist[["Labels"]][6:8], label_size = 18)#> Error in plot_grid(plist[["Plots"]][[6]], plist[["Plots"]][[7]], plist[["Plots"]][[8]], ncol = 3, nrow = 1, labels = plist[["Labels"]][6:8], label_size = 18): could not find function "plot_grid"p22 <- plot_grid(plist[["Plots"]][[9]], plist[["Plots"]][[10]], ncol = 2, nrow = 1, labels = plist[["Labels"]][9:10], label_size = 18)#> Error in plot_grid(plist[["Plots"]][[9]], plist[["Plots"]][[10]], ncol = 2, nrow = 1, labels = plist[["Labels"]][9:10], label_size = 18): could not find function "plot_grid"plot_grid(p1, p12, p2, p22, ncol = 1)#> Error in plot_grid(p1, p12, p2, p22, ncol = 1): could not find function "plot_grid"