Description Usage Arguments Examples
Plot the decision boundary of SVM model with 2 features
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | plot_svm_jk(
df,
svm_model = NULL,
grid = 50,
tolerance = 0.005,
color = c("#56b4e9", "#e69f00", "black"),
plot_grid = T,
plot_contour = T,
plot_decision = T,
fill_plot = F,
fillmap = NULL,
bins = 10,
contour_color = "white",
longer_legend = T,
add_title = T,
surface_plot = F,
title = "SVM - Visualization",
plot_data = T,
ESL_theme = F,
subtitle = T,
...
)
|
df |
The data to be displayed in this layer. |
svm_model |
svm model from library e1071 or kernlab |
grid |
Size of the grid used for sampling the space. We have to evaluate the decision function f(x) in each point. |
tolerance |
when ploting the contours for the decision function f(x) = +-1, how close need the points to be to that line in order to be highlighted. |
color |
3 color vector. First two colors used for datapoints, third one used for the contours. |
plot_grid |
should the grid be plotted. Default value is TRUE. |
plot_contour |
should the contour for f(x) = +-1 be plotted. Default value is TRUE. This setting doesn't affect the contours for fill_plot. |
plot_decision |
should the decision boundary(the contour for f(x)=0) be plotted. Default value is TRUE. |
fill_plot |
should the plot be filled according to distance to the decision boundary. Classes have different shape. Filled shape means the point is a support vector. Default value is FALSE. |
fillmap |
colormap used for the fill_plot. Consider using diverging color pallete. Many available in the pals package. |
bins |
number of bins used for geom_contour in fill_plot. |
contour_color |
color used for contours in fill_plot. |
longer_legend |
should the legend be as long as the plot. Default value is TRUE. |
add_title |
should the title be added. Default value is TRUE. |
surface_plot |
should we plot the "decision" function f(x): R^2 -> R. Default value is FALSE. |
title |
string title for the plot. |
plot_data |
should the original data be plotted? Default value is TRUE. |
ESL_theme |
should x and y be without labels and ticks? Default value is FALSE. |
subtitle |
should default subtitle be added. Default value is TRUE. |
... |
additional paramaters when calling the persp_jk function. |
1 2 3 4 5 6 7 8 9 10 | data(df)
library(e1071)
model <- svm(label ~ x1 + x2, data = df, kernel = "radial", gamma = 1, scale = F, cost = 1.8)
plot_svm_jk(df,model, ESL_theme = T)
## filled plot
plot_svm_jk(df,model,fill_plot = T, plot_contour = F, plot_decision = F)
## surface plot
plot_svm_jk(df,model,surface_plot = T, theta = 300)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.