View source: R/OptimInstanceBatchSingleCrit.R
autoplot.OptimInstanceBatchSingleCrit | R Documentation |
Visualizations for bbotk::OptimInstanceBatchSingleCrit.
The argument type
controls what kind of plot is drawn.
Possible choices are:
"marginal"
(default): Scatter plots of x versus y.
The color of the points shows the batch number.
"performance"
: Scatter plots of batch number versus y
"parameter"
: Scatter plots of batch number versus input.
The color of the points shows the y values.
"parallel"
: Parallel coordinates plot.
x values are rescaled by (x - mean(x)) / sd(x)
.
"points"
: Scatter plot of two x dimensions versus.
The color of the points shows the y values.
"surface"
: Surface plot of two x dimensions versus y values.
The y values are interpolated with the supplied mlr3::Learner.
"pairs"
: Plots all x and y values against each other.
"incumbent"
: Plots the incumbent versus the number of configurations.
## S3 method for class 'OptimInstanceBatchSingleCrit'
autoplot(
object,
type = "marginal",
cols_x = NULL,
trafo = FALSE,
learner = mlr3::lrn("regr.ranger"),
grid_resolution = 100,
batch = NULL,
theme = theme_minimal(),
...
)
object |
(bbotk::OptimInstanceBatchSingleCrit). |
type |
(character(1)): |
cols_x |
( |
trafo |
( |
learner |
(mlr3::Learner) |
grid_resolution |
( |
batch |
( |
theme |
( |
... |
(ignored). |
ggplot2::ggplot()
.
if (requireNamespace("mlr3") && requireNamespace("bbotk") && requireNamespace("patchwork")) {
library(bbotk)
library(paradox)
fun = function(xs) {
c(y = -(xs[[1]] - 2)^2 - (xs[[2]] + 3)^2 + 10)
}
domain = ps(
x1 = p_dbl(-10, 10),
x2 = p_dbl(-5, 5)
)
codomain = ps(
y = p_dbl(tags = "maximize")
)
obfun = ObjectiveRFun$new(
fun = fun,
domain = domain,
codomain = codomain
)
instance = oi(objective = obfun, terminator = trm("evals", n_evals = 20))
optimizer = opt("random_search", batch_size = 2)
optimizer$optimize(instance)
# plot y versus batch number
print(autoplot(instance, type = "performance"))
# plot x1 values versus performance
print(autoplot(instance, type = "marginal", cols_x = "x1"))
# plot parallel coordinates plot
print(autoplot(instance, type = "parallel"))
# plot pairs
print(autoplot(instance, type = "pairs"))
# plot incumbent
print(autoplot(instance, type = "incumbent"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.