ssvm is the Simple SVM package. It has a 2-class linear SVM implementation using the Pegasos algorithm, written on my day off for fun. The design philosophy for the project is:
The development version is maintained on GitHub, and can easily be installed by any of the packages that offer installations from GitHub:
### Pick your preference
devtools::install_github("wrathematics/ssvm")
ghit::install_github("wrathematics/ssvm")
remotes::install_github("wrathematics/ssvm")
library(ssvm)
y <- recode(iris$Species == "setosa")
x <- as.matrix(iris[, -5])
set.seed(1234)
mdl <- pegasos(x, y)
mdl
## SVM model (Method=Pegasos, Iterations=1e+05)
## Intercept Sepal.Length Sepal.Width Petal.Length Petal.Width
## -0.08139028 -0.12708726 -0.45953076 0.68090852 0.33553786
mdl <- pegasos(x, y, intercept=FALSE)
mdl
## SVM model (Method=Pegasos, Iterations=1e+05)
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## -0.1358138 -0.4659208 0.6824105 0.3382079
p <- predict(mdl, x)
sum(which(p != y))
## 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.