Predicts class labels across a 2-D grid using the complete tree (not individual node SVMs), then overlays the original data points. Because predictions come from svm_predict_tree, multiclass trees are handled correctly - each grid cell receives the final leaf prediction which respects all OVR splits along the path.

plot_surface(tree, data, response, features = NULL, resolution = 200)

Arguments

tree

An svmodt_node object returned by svm_split.

data

The original training data frame.

response

Character string naming the response column in data.

features

Character vector of length 2 giving the two features to plot on the x and y axes. Defaults to the first two features used at the root.

resolution

Integer; grid resolution per axis (default 200). Higher values give smoother region boundaries.

Value

A ggplot2 object. The background tiles show the predicted class for each grid cell; points show true class labels.

Details

All features not used as plot axes are held fixed at their in-sample median (numeric) or mode (categorical). You choose which two features to plot via features; if omitted the first two features used at the root node are used.