plot.gensvm: Plot the simplex space of the fitted GenSVM model

View source: R/plot.gensvm.R

plot.gensvmR Documentation

Plot the simplex space of the fitted GenSVM model

Description

This function creates a plot of the simplex space for a fitted GenSVM model and the given data set. This function works for dataset with two or three classes. For more than 3 classes, the simplex space is too high dimensional to easily visualize.

Usage

## S3 method for class 'gensvm'
plot(
  x,
  labels,
  newdata = NULL,
  with.margins = TRUE,
  with.shading = TRUE,
  with.legend = TRUE,
  center.plot = TRUE,
  xlim = NULL,
  ylim = NULL,
  ...
)

Arguments

x

A fitted gensvm object

labels

the labels to color points with. If this is omitted the predicted labels are used.

newdata

the dataset to plot. If this is NULL the training data is used.

with.margins

plot the margins

with.shading

show shaded areas for the class regions

with.legend

show the legend for the class labels

center.plot

ensure that the boundaries and margins are always visible in the plot

xlim

allows the user to force certain plot limits. If set, these bounds will be used for the horizontal axis.

ylim

allows the user to force certain plot limits. If set, these bounds will be used for the vertical axis and the value of center.plot will be ignored

...

further arguments are passed to the builtin plot() function

Value

returns the object passed as input

Author(s)

Gerrit J.J. van den Burg, Patrick J.F. Groenen
Maintainer: Gerrit J.J. van den Burg <gertjanvandenburg@gmail.com>

References

Van den Burg, G.J.J. and Groenen, P.J.F. (2016). GenSVM: A Generalized Multiclass Support Vector Machine, Journal of Machine Learning Research, 17(225):1–42. URL https://jmlr.org/papers/v17/14-526.html.

See Also

plot.gensvm.grid, predict.gensvm, gensvm, gensvm-package

Examples

x <- iris[, -5]
y <- iris[, 5]

# train the model
fit <- gensvm(x, y)

# plot the simplex space
plot(fit)

# plot and use the true colors (easier to spot misclassified samples)
plot(fit, y)

# plot only misclassified samples
x.mis <- x[predict(fit) != y, ]
y.mis.true <- y[predict(fit) != y]
plot(fit, newdata=x.mis)
plot(fit, y.mis.true, newdata=x.mis)

# plot a 2-d model
xx <- x[y %in% c('versicolor', 'virginica'), ]
yy <- y[y %in% c('versicolor', 'virginica')]
fit <- gensvm(xx, yy, kernel='rbf', max.iter=1000)
plot(fit)


gensvm documentation built on Feb. 16, 2023, 5:58 p.m.