SVM in R taking too much time


#1

I am trying to apply SVM for 10,00,000 data set in R(using e1071 library). It keeps processing after 24 hrs, what can I do?
I also want a detailed source for SVM ( its implementation and theory).
Thanks


#2

hi @syed.danish,

Have you gone through:

http://www.analyticsvidhya.com/blog/2015/10/understaing-support-vector-machine-example-code/

Hope the below R Code helps you!!

rm(list = ls())
letters <- read.csv('https://raw.githubusercontent.com/stedy/Machine-Learning-with-R-datasets/master/letterdata.csv')
str(letters)

#Split into test and train:
letters_train <- letters[1:16000, ]
letters_test <- letters[16001:20000,]

library(kernlab)
letter_classifier <- ksvm(letter ~ ., data = letters_train,kernel = "vanilladot")
letter_classifier

#predictions:
letter_predictions <- predict(letter_classifier, letters_test)
#Check the accuracy:
caret::confusionMatrix(letter_predictions,letters_test$letter)
agreement <- letter_predictions == letters_test$letter
prop.table(table(agreement))
#We get an accuracy of 84% with a simple linear kernel,let's try with RBF kernel:
letter_classifier_rbf <- ksvm(letter ~ ., data = letters_train,kernel = "rbfdot")

#predictions:
letter_predictions <- predict(letter_classifier_rbf,letters_test)
#Check the accuracy:
caret::confusionMatrix(letter_predictions,letters_test$letter)
agreement <- letter_predictions == letters_test$letter
prop.table(table(agreement))

#3

Hi @syed.danish

First 24 hours is not too bad !!! It depends which implementation some used neural net in background and to converge it takes times, I red yesterday weeks but this was neural net and pattern matching !!!
Anyway if you have the time to look at a good impelementation, go there SVM
Tong He is the person behind xgboost package for R !! this implementation uses ensemble and if you look at the reference it uses one algorithm method of Yoshi Bengio … so pretty clever …
Have fun and tell me what you think about this implementation

Have a good time

Alain