Classifying using Support Vector Machine
The e1071
package can help you to easily apply the very powerful Support Vector Machine (SVM) classification technique.
Getting ready
If you have not already installed the e1071
and caret
packages, install them now. Download the data files for this chapter from the book's website and place the banknote-authentication.csv
file in your R working directory. We will build an SVM model to predict class
based on the other variables.
How to do it...
To classify using SVM, follow these steps:
- Load the
e1071
andcaret
packages:> library(e1071) > library(caret)
- Read the data:
> bn <- read.csv("banknote-authentication.csv")
- Convert the outcome variable class to a factor:
> bn$class <- factor(bn$class)
- Partition the data:
> set.seed(1000) ...
Get R: Recipes for Analysis, Visualization and Machine Learning now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.