Convert to visualizer
as_visualizer.Rd
This function converts to a visualizer. Automatically chooses between 1D and 2D visualizations based on the number of features/dimensions using ggplot2 backend. For 2D inputs, you can optionally use `type = "surface"` to get interactive plotly surface plots (available for Models and Objectives only).
Usage
as_visualizer(
x,
type = "auto",
x1_limits = NULL,
x2_limits = NULL,
padding = 0,
n_points = 100L,
y_pred = NULL,
y_true = NULL,
input_type = "auto",
y_curves = "both",
learner = NULL,
...
)
# S3 method for class 'Task'
as_visualizer(
x,
type = "auto",
x1_limits = NULL,
x2_limits = NULL,
padding = 0,
n_points = 100L,
y_pred = NULL,
y_true = NULL,
input_type = "auto",
y_curves = "both",
learner = NULL,
...
)
# S3 method for class 'Objective'
as_visualizer(
x,
type = "auto",
x1_limits = NULL,
x2_limits = NULL,
padding = 0,
n_points = 100L,
y_pred = NULL,
y_true = NULL,
input_type = "auto",
y_curves = "both",
learner = NULL,
...
)
# S3 method for class 'LossFunction'
as_visualizer(
x,
type = "auto",
x1_limits = NULL,
x2_limits = NULL,
padding = 0,
n_points = 1000L,
y_pred = NULL,
y_true = NULL,
input_type = "auto",
y_curves = "both",
learner = NULL,
...
)
# S3 method for class 'list'
as_visualizer(
x,
type = "auto",
x1_limits = NULL,
x2_limits = NULL,
padding = 0,
n_points = 1000L,
y_pred = NULL,
y_true = NULL,
input_type = "auto",
y_curves = "both",
learner = NULL,
...
)
Arguments
- x
(`any`)
Object to convert to a visualizer.- type
(`character(1)`)
The type of visualization: "auto" (default), "1d", "2d", or "surface". If "auto", automatically chooses between 1D and 2D ggplot2 visualizations based on the number of features/dimensions. Use "surface" for interactive plotly surface plots (2D inputs only, Models and Objectives only).- x1_limits
(`numeric(2)`)
The x1 limits.- x2_limits
(`numeric(2)`)
The x2 limits.- padding
(`numeric(1)`)
A margin that is added to x1limits and x2limits. The x1 margin is calculated by `max(x1lmits) - min(x1limits) * padding`.- n_points
(`integer(1)`)
The number of generated point per dimension. Note that a grid of `npoints^2` values is generated and evaluated by `objective$eval(x)` to plot the surface.- y_pred
(`numeric()`)
Predicted values (used for loss function visualizations).- y_true
(`numeric()`)
True values (used for loss function visualizations).- input_type
(`character(1)`)
`"auto"` (default), `"score"` or `"probability"`. Passed through to the loss visualiser.- y_curves
(`character(1)`)
Which response curve(s) to draw when `input_type = "probability"`. One of `"both"`, `"y1"`, or `"y0"`.- learner
(`mlr3::Learner`)
The learner to train the model with.- ...
(`any`)
Additional arguments.
Value
An object inheriting from a Visualizer class (Visualizer1D, Visualizer2D, VisualizerSurface, etc.) depending on the input and selected type.
Details
If `type = "auto"` (default), the function will inspect the input and select the appropriate ggplot2 visualizer: - 1D: For objects with 1 feature/dimension (uses ggplot2) - 2D: For objects with 2 features/dimensions (uses ggplot2) You can override this by specifying `type = "1d"`, `type = "2d"`, or for 2D inputs only: `type = "surface"` (uses plotly for interactive surfaces, Models and Objectives only).