MyNixOS website logo
Description

Stream Suitable Online Support Vector Machines.

Soft-margin support vector machines (SVMs) are a common class of classification models. The training of SVMs usually requires that the data be available all at once in a single batch, however the Stochastic majorization-minimization (SMM) algorithm framework allows for the training of SVMs on streamed data instead Nguyen, Jones & McLachlan(2018)<doi:10.1007/s42081-018-0001-y>. This package utilizes the SMM framework to provide functions for training SVMs with hinge loss, squared-hinge loss, and logistic loss.

CRAN_Status_Badge Travis-CI BuildStatus DOI

SSOSVM

The goal of SSOSVM is to use R to allow batch and online training of soft-margin support vector machines (SVMs). The training of SVMs usually requires that the data be available all at once in a single batch, however the Stochastic majorization-minimization (SMM) algorithm framework allows for the training of SVMs on streamed data instead http://doi.org/10.1007/s42081-018-0001-y. This package utilizes the SMM framework to provide functions for training SVMs with hinge loss, squared-hinge loss, and logistic loss, functions.

Installation

You can install SSOSVM from github with:

# install.packages("devtools")
devtools::install_github("andrewthomasjones/SSOSVM")

Example

Here is a very simple example using simulated data:

#setup
library(SSOSVM)
library(ggplot2)

#simulations
sims <- generateSim(100, DELTA=3)

#fit using various loss functions
sq1<-SVMFit(sims$YMAT,"square")
h1<-SVMFit(sims$YMAT,"hinge")
l1<-SVMFit(sims$YMAT,"logistic")

#plot results
plot<-ggplot(data.frame(sims$YMAT), aes(colour=factor(YY), x=V2, y=V3))
plot<-plot+geom_point()+theme_bw()+xlab("X")+ylab("Y")+guides(colour=FALSE)
plot<-plot+geom_abline(intercept=sq1$THETA[1],
                       slope=sq1$THETA[2]/sq1$THETA[3], colour="blue")
plot<-plot+geom_abline(intercept=h1$THETA[1],
                       slope=h1$THETA[2]/h1$THETA[3], colour="green")
plot<-plot+geom_abline(intercept=l1$THETA[1],
                       slope=l1$THETA[2]/l1$THETA[3], colour="red")
plot

Animated figures

Here is an animated example to demostrate the online nature of of the SSOSVM method:

library(ggplot2)
library(gganimate)

#set up
sims <- generateSim(10^2, DELTA=1.5)

#fit using various loss functions
sq1<-SVMFit(sims$YMAT,"square", returnAll = TRUE)
h1<-SVMFit(sims$YMAT,"hinge", returnAll = TRUE)
l1<-SVMFit(sims$YMAT,"logistic", returnAll = TRUE)

#dataframe
data<-data.frame(sample=1:10^2, 
                 sims$YMAT,
                 logistic_int=l1$THETA_list[,1],
                 square_int=sq1$THETA_list[,1],
                 hinge_int=h1$THETA_list[,1],
                 logistic_sl=l1$THETA_list[,2]/l1$THETA_list[,3],
                 square_sl=sq1$THETA_list[,2]/sq1$THETA_list[,3],
                 hinge_sl=h1$THETA_list[,2]/h1$THETA_list[,3])  

#base plot
plot<-ggplot(data, aes(colour=factor(YY), x=V2, y=V3))+ 
  geom_point(size=2)+theme_bw()+xlab("X")+ylab("Y")+
  guides(colour=FALSE)+geom_abline(size=1.6,alpha=.5, aes(intercept=square_int, slope=square_sl))

#animate
example <- plot + transition_time(sample)+
  labs(title =  "Sample: {frame_time}")+
  shadow_mark(alpha = 1, size = 1, exclude_layer = 2)

#save animation
anim_save("./inst/example.gif", example, fps=2.5)

Metadata

Version

0.2.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows