machine learning - error tuning SVM in R -
i'm tuning svm in r , receive following error:
#error in if (any(co)) { : missing value true/false needed
i'm using caret package
svmrtune <- train(x=datatrain[,predmodelcontinuous],y=datatrain[,outcome],method = "svmradial", tunelength = 14, trcontrol = trctrl)
the training set structure is
str(datatrain) 'data.frame': 40001 obs. of 42 variables: $ polnum : num 2e+08 2e+08 2e+08 2e+08 2e+08 ... $ sex : factor w/ 2 levels "male","female": 1 1 1 2 1 2 1 1 1 2 ... $ type : factor w/ 6 levels "a","b","c","d",..: 3 1 1 2 2 4 3 3 3 2 ... $ catgry : ord.factor w/ 3 levels "large"<"medium"<..: 2 2 2 3 3 3 3 2 2 2 ... $ occup : factor w/ 5 levels "employed","housewife",..: 2 1 1 1 5 4 1 1 4 2 ... $ age : num 48 23 23 39 24 39 28 43 45 38 ... $ group : factor w/ 20 levels "1","2","3","4",..: 15 16 12 16 14 8 16 9 12 8 ... $ bonus : ord.factor w/ 21 levels "-50"<"-40"<"-30"<..: 14 8 4 3 5 2 5 5 1 15 ... $ poldur : num 7 1 1 14 2 4 11 2 8 5 ... $ value : num 1120 21755 18430 11930 24850 ... $ adind : factor w/ 2 levels "no","yes": 2 1 1 2 1 2 2 2 1 1 ... $ pcode : chr "sc22" "ct109" "ma1" "sa12" ... $ area : factor w/ 10 levels "ct","ju","ma",..: 7 1 3 6 6 6 6 4 1 2 ... $ density : num 270.5 57.3 43.2 167.9 169.8 ... $ prem : num 1159 532 527 197 908 ... $ premad : num 53.1 413.7 410.7 61.6 824.6 ... $ numclm : num 0 1 0 1 0 0 0 1 0 0 ... $ invite : num 1 1 1 1 1 1 1 1 1 1 ... $ renewaltp : num 1302 928 632 291 960 ... $ renewalad : num 58.4 599 440.4 71.3 682 ... $ markettp : num 1110 884 565 253 833 ... $ marketad : num 53.4 611.4 431.6 55.5 587 ... $ premtot : num 1212 532 527 259 908 ... $ renewaltot : num 1361 928 632 362 960 ... $ markettot : num 1163 884 565 309 833 ... $ renew : ord.factor w/ 2 levels "no"<"yes": 1 1 1 1 1 1 1 1 1 1 ... $ premchng : num 1.12 1.74 1.2 1.4 1.06 ... $ compmeas : num 1.17 1.05 1.12 1.17 1.15 ... $ numclmrec : ord.factor w/ 3 levels "none"<"one"<"two or more": 1 2 1 2 1 1 1 2 1 1 ... $ premchngrec: factor w/ 20 levels "[0.546,0.758)",..: 16 20 18 19 14 3 7 19 17 11 ... $ agerec : factor w/ 20 levels "[19,22)","[22,25)",..: 14 2 2 9 2 9 4 11 12 9 ... $ valuerec : factor w/ 20 levels "[ 1005, 3290)",..: 1 15 13 9 17 5 12 12 19 1 ... $ densityrec : factor w/ 20 levels "[ 14.4, 25.0)",..: 19 6 5 15 15 13 15 1 5 11 ... $ compmeasrec: factor w/ 20 levels "[0.716,0.869)",..: 12 6 10 13 12 18 11 16 18 14 ... $ poldurrec : ord.factor w/ 16 levels "1"<"2"<"3"<"4"<..: 7 1 1 14 2 4 11 2 8 5 ... $ agest : num 0.407 -1.34 -1.34 -0.222 -1.27 ... $ numclmst : num -0.433 1.627 -0.433 1.627 -0.433 ... $ premchngst : num 0.591 3.709 0.98 1.985 0.265 ... $ valuest : num -1.462 0.499 0.183 -0.434 0.793 ... $ densityst : num 1.918 -0.748 -0.924 0.636 0.659 ... $ compmeasst : num 0.224 -0.539 -0.098 0.248 0.113 ... $ poldurst : num 0.097 -1.2 -1.2 1.61 -0.984 ...
and
sessioninfo() r version 3.0.2 (2013-09-25) platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] lc_collate=italian_italy.1252 lc_ctype=italian_italy.1252 [3] lc_monetary=italian_italy.1252 lc_numeric=c [5] lc_time=italian_italy.1252 attached base packages: [1] parallel splines grid stats graphics grdevices utils [8] datasets methods base other attached packages: [1] c50_0.1.0-16 kernlab_0.9-19 nnet_7.3-8 plyr_1.8.1 [5] gbm_2.1 randomforest_4.6-7 rpart_4.1-8 klar_0.6-10 [9] mass_7.3-31 doparallel_1.0.8 iterators_1.0.6 foreach_1.4.1 [13] proc_1.7.1 mda_0.4-4 class_7.3-10 earth_3.2-7 [17] plotrix_3.5-5 plotmo_1.3-3 formula_1.1-1 survival_2.37-7 [21] caret_6.0-24 ggplot2_0.9.3.1 lattice_0.20-29 rj_1.1.3-1 loaded via namespace (and not attached): [1] car_2.0-19 cluster_1.15.2 codetools_0.2-8 [4] colorspace_1.2-4 combinat_0.0-8 compiler_3.0.2 [7] dichromat_2.0-0 digest_0.6.4 gtable_0.1.2 [10] hmisc_3.14-3 labeling_0.2 latticeextra_0.6-26 [13] munsell_0.4.2 proto_0.3-10 rcolorbrewer_1.0-5 [16] rcpp_0.11.1 reshape2_1.2.2 rj.gd_1.1.3-1 [19] scales_0.2.3 stringr_0.6.2 tools_3.0.2
just posting in case else runs across problem. appears caused including factor or character variable in training data set.
why svm can not take factor variable, not know. replaced factors hand coded dummies, , worked fine, approach inelegant document.
Comments
Post a Comment