Learn R Programming

e1071 (version 1.3-16)

plot.svm: Plot svm objects

Description

Generates a scatter plot of the input data of a svm fit for classification models by highlighting the classes and support vectorts. Optionally, draws filled contour plot of the class regions.

Usage

plot.svm(x, data, formula, fill = TRUE, grid = 50, slice = list(), ...)

Arguments

x
An object of class svm
data
data to visualize. Should be the same used for fitting.
formula
formula selecting the visualized two dimensions. Only needed if more than two input variables are used.
fill
switch indicating whether a contour plot for the class regions should be added.
grid
granularity for the contour plot.
slice
a list of named numeric values for the dimensions held constant (only needed if more than two variables are used). Dimensions not specified are fixed at 0.
...
additional graphics parameters passed to filled.contour and plot.

See Also

svm

Examples

Run this code
## a simple example
library(MASS)
data(cats)
m <- svm(Sex~., data = cats)
plot(m, cats)

## more than two variables: fix 2 dimensions
data(iris)
m2 <- svm(Species~., data = iris)
plot(m2, iris, Petal.Width ~ Petal.Length,
     slice = list(Sepal.Width = 3, Sepal.Length = 4))

Run the code above in your browser using DataLab