R : Rsofia convert sparse.model.matrix to SVM-light format -


i have data set of ~ 25kr x 10c. several of columns contain large numbers of levels in categorical variables. i'm trying convert data set svm-light format using rsofia package getting following error

error in model.matrix.default(formula, data) :    allocmatrix: many elements specified 

i have converted data set sparse.model.matrix object using matrix package curious if it's possible write svm-light formatted file sparse.model.matrix object.

my code below:

library(rsofia) library(matrix)  n = 100000 df1 <- data.frame(id = 1:n, target = round(runif(n),0), col1 = factor(letters[sample(1:26,n,replace = t)])         , col2 = factor(letters[sample(1:26,n,replace = t)])         , col3 = round(runif(n)*1000,0)         ) df1$col4 <- with(df1,factor(paste(col2, col3, sep = ''))) head(df1);length(unique(df1$col4)) str(df1)  varstouse <- c('col1','col2','col3', 'col4')  smm1 <- sparse.model.matrix(df1$target ~ 0 +., data = df1[,varstouse]) 

i errors when run code:

x <- parse_formula(smm1$target ~ 0 +., data = smm1[,varstouse]) x <- parse_formula(df1$target ~ 0 +., data = df1[,varstouse])  tmp <- tempfile() write.svmlight(x$labels, x$data, tmp); readlines(tmp) 

any suggestions?


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -