Home > Net >  Svm Multi-Classification in R
Svm Multi-Classification in R

Time:06-06

I am using the SVM model for the classification of the data given below, but I don't know why I am getting this error. I have tried using two methods but both are not working. Please help me I am stuck for a very long. I have seen many posts here and tried to specify my model for classification but no results.

My data:

structure(list(pCAMKII_N = c(-0.145868903106222, -0.0757245672281776, 
0.23642582674556, 0.148460249143042, -0.00305230227892469, 0.0585561745843138, 
-0.148682825543474, -0.21730129212525, 0.459967321113158, 0.422894418061546, 
-0.0575744512697957, -0.127564153510276, -0.242697988154887, 
-0.095402375827381, 0.0140296834402993, -0.0497934688280284), 
    pCREB_N = c(-0.0825121744625299, -0.026500034184616, 0.0674710705932882, 
    -0.171872159375326, 0.0599673008600893, 0.20274815322096, 
    -0.138321776880784, -0.179229652914255, -0.031683391484602, 
    -0.107073356219089, 0.0795112065683711, 0.0230878800052553, 
    -0.101810049763974, 0.141596706516054, 0.175052271845758, 
    0.0962492148671607), pMEK_N = c(-0.011827795918493, 0.0651085636651456, 
    0.0372073300493682, -0.0758375679929981, 0.038855171657283, 
    0.162735732819232, -0.129245969397597, -0.10183076411972, 
    -0.030313508584495, -0.0402009321267793, 0.0265091904210039, 
    0.0384635318143068, -0.145082961476379, -0.00383809286152744, 
    0.00274224616628268, 0.0325875706999738), pNR2A_N = c(-0.040694436939677, 
    -0.126422726919893, 0.327029496785507, 0.11289764061805, 
    0.00949037400844992, -0.0370143413154391, -0.0445050341199518, 
    -0.0875679863319538, -0.0318024269145471, -0.0990796159280345, 
    0.114103842731325, 0.0684955162565601, -0.0517765103296767, 
    0.0262937180568668, 0.0186704564656926, -0.069607116867091
    ), pPKCAB_N = c(-0.0732668154024626, 0.259508683035786, -0.156388727351903, 
    -0.128555140589917, 0.233485439385613, -0.109922421599626, 
    -0.230899862755971, -0.275680739843144, 0.202586893320354, 
    0.128569221313288, -0.187404269824716, -0.123823456903658, 
    -0.0510954627942524, 0.224263475958852, -0.110903224987034, 
    -0.0622911739357286), pRSK_N = c(-0.0830647198678661, 0.171345235902955, 
    -0.00771685629829743, -0.153792422272828, 0.0775638466765593, 
    0.0562653498716256, -0.138802407016646, -0.115702091265824, 
    0.161592613345935, 0.120453263851679, -0.0389173648044295, 
    -0.0711265266002543, -0.207578315767319, -0.0270749356104633, 
    0.0589442953743869, 0.0144541906539012), AKT_N = c(0.0481798874438209, 
    -0.0923315388558725, -0.108885641561443, -0.105416833062579, 
    0.144880510212411, 0.00523331467580219, 0.0328578246677392, 
    0.0571445022606188, -0.0209256486347021, -0.0730029998614634, 
    0.0440023583125468, 0.0717278333163182, 0.0196560602422922, 
    0.0988713938163715, 0.0527286790966814, 0.0229037502299382
    ), BRAF_N = c(-0.00321939692704801, 0.0962073093317588, -0.0677402898524546, 
    -0.067209980101031, -0.0192180601759131, 0.0499710838529006, 
    -0.0685860451987449, -0.0621210254646294, 0.0464452196252293, 
    0.0717595906404571, -0.0808646010953599, -0.070139309127312, 
    0.0260226905885634, 0.0307477583500104, -0.0495839406552054, 
    -0.0605696564634389), CREB_N = c(0.0633377024959499, 0.0719351180508572, 
    0.0554860017614535, -0.0754709592333137, -0.051730811130647, 
    0.0770585706175764, -0.119490365368989, -0.101979827161643, 
    0.0390935428793637, 0.0334190803939948, -0.0231648718807617, 
    0.175244016989004, -0.199464488371739, -0.0830526740916612, 
    -0.0236000029056659, -0.0555939459680455), ERK_N = c(0.113758147959477, 
    -0.0935376622896181, -0.194533549084613, -0.202343017546552, 
    0.368811506067506, 0.0211924441765911, -0.166177103411079, 
    -0.239377414372715, 0.0512242092661902, -0.030723497203822, 
    0.00664926832340125, -0.105494671248667, 0.143740808738886, 
    0.306473059519756, 0.068383724577022, 0.0171957013321164), 
    GSK3B_N = c(0.0496851372868314, 0.0965673122890421, -0.122194260011564, 
    -0.113614901308566, 0.147165890990766, -0.0568100186969033, 
    -0.150554531109297, -0.188598927874271, 0.0729314311629536, 
    0.0534454310403283, -0.0530979322493377, -0.108715383018256, 
    0.0774398337859832, 0.133178525946526, 0.00917139328707758, 
    0.00415362892452407), JNK_N = c(0.084671436503407, 0.091451395958942, 
    -0.0735719764555032, -0.128089296490928, 0.0482424225269525, 
    0.136559678562216, -0.0983547253737015, -0.0994914255127194, 
    0.00287013911408683, -0.0207264777165356, -0.0425235674499462, 
    -0.0328911666055918, -0.102415581508767, 0.0426548346554378, 
    -0.0453706640514963, 0.0837146521123543), MEK_N = c(0.0415145904202766, 
    0.000112891679066114, -0.0947656593375573, -0.161573116350825, 
    0.217458153608386, 0.132508968100251, -0.177468380610068, 
    -0.18842935475728, 0.00445721815704893, -0.0539245065836939, 
    -0.00307155552655238, 0.0116656936964918, -0.100533579935951, 
    0.19149971269713, 0.15252996223312, 0.0956503457831564), 
    RSK_N = c(0.0191395815813382, 0.0714942086955356, 0.0161998863368589, 
    -0.184560332102979, -0.0264979202843543, 0.298908704096619, 
    -0.0968942910305665, -0.0189051673871464, 0.0861641375591587, 
    0.0160470100470935, -0.0682290713635209, -0.0518589639648677, 
    -0.23241046414349, -0.0542963774080875, -0.0873418795312474, 
    0.0210347924349621), APP_N = c(-0.0806791681338731, -0.0704201146133004, 
    -0.190200351582733, -0.162718360121692, 0.0303369406177179, 
    -0.0860104704967967, -0.162468694656265, -0.186756215303488, 
    0.149403011555697, 0.0234829670280346, 0.0759128457278766, 
    0.0934903179979386, 0.105907786308873, 0.361038543968712, 
    0.0786334044736174, 0.0784404724592734), Bcatenin_N = c(-0.0609377198837611, 
    -0.111471497502357, -0.0866850028872295, -0.134271109042703, 
    0.197879694030571, -0.025717790316679, -0.114779722205815, 
    -0.215166874658, 0.093663448787465, -0.0106410825979063, 
    0.0856165346234392, -0.0915811784652404, -0.0313801262102451, 
    0.220238809782054, 0.13789742580927, 0.141644968613549), 
    SOD1_N = c(-0.123838690502292, -0.144130158837663, 0.0727560720797953, 
    -0.0681671745118475, -0.123567494179754, -0.117023734873497, 
    0.253293745880715, 0.185224720298962, -0.11802985927293, 
    -0.143547249900102, 0.47503997511273, 0.434217391632064, 
    -0.15212803487222, -0.106940962031447, 0.100783205025425, 
    0.363303202025603), P38_N = c(0.0135880916776172, -0.0645721208196919, 
    0.0948843285406695, 0.159312513843406, -0.0770493007707386, 
    -0.107486334544236, 0.150819778231829, 0.217491472288877, 
    -0.121236098381148, -0.130587965985436, 0.0116164053669351, 
    0.144776197754908, -0.158244000282848, -0.13848656873568, 
    0.0539113322660321, -0.0721957070846476), DSCR1_N = c(0.0873105225377593, 
    -0.0399938541478373, -0.0423959808617725, 0.0615326056646092, 
    -0.0290529787358271, 0.0522204008570095, -0.0475227862097225, 
    0.0308446987929902, -0.0305665225181376, -0.0607456490874483, 
    0.0279790218604084, 0.100583918291236, -0.0206748799372295, 
    0.010415281028328, -0.0414425004790977, -0.0489198196614915
    ), NR2B_N = c(0.106299550498296, -0.0381078612482542, -0.00101679889831333, 
    0.0267320329216243, 0.112439396399247, -0.064052196844109, 
    -0.00641666140192624, 0.0613191854808411, 0.0168607292707449, 
    -0.0487573287523953, -0.0439584530719966, 0.00809905456774659, 
    -0.0667726467406412, 0.0694971401183639, -0.000212905759537097, 
    0.0163350414150324), pNUMB_N = c(0.202564418361944, -0.00200124352888242, 
    -0.0998561853278869, 0.037524195854859, 0.149886434896155, 
    0.195128273020257, -0.195094705493063, -0.140281085662283, 
    0.0590093896988644, 0.00582004770130322, -0.0546687365873218, 
    0.0551625036706637, 0.0777195935539914, 0.036101539026412, 
    0.0107519309923, -0.103469871374173), TIAM1_N = c(0.058847821102376, 
    -0.159760016471791, -0.0979806570256097, 0.0531257042802172, 
    0.103564419565561, -0.0238368367628548, -0.0729210307202995, 
    -0.06325777516333, -0.0281144756311353, -0.0884600747007959, 
    0.00512281704622422, 0.0615056543435742, -0.00313409869767671, 
    0.0899369569840853, 0.120845861658354, -0.00443043623680605
    ), pP70S6_N = c(-0.217859954507296, 0.243521933127221, 0.0425412592499045, 
    0.0832466388027541, -0.0874992096268626, -0.14876403578688, 
    -0.00476984544201101, 0.0106283984338779, 0.114328759061199, 
    0.125171996276406, -0.0925437220067121, -0.0570200090555343, 
    -0.252313164764891, -0.183959220656612, 0.189234923062614, 
    0.179602221371295), NUMB_N = c(0.0507161136495314, -0.0428893884462266, 
    -0.0737803369486708, -0.125816787402445, 0.157329290628144, 
    -0.0618269592229841, -0.121271771020323, -0.208391773663935, 
    0.0398518709801874, -0.015557253715229, -0.0686033888733257, 
    -0.146899366608736, 0.229868831769603, 0.328004434107362, 
    0.262082754277244, 0.270980403077601), P70S6_N = c(-0.0467645544881666, 
    -0.0513422563937406, 0.0806193466797829, -0.097604174996586, 
    0.169381505159102, -0.10953472581413, -0.0762873839439222, 
    -0.137957724239911, -0.0404929923772219, -0.112679782727059, 
    0.0478687778434949, -0.135047834380878, 0.235505540876976, 
    0.101996139976229, 0.0881984401256723, 0.0308682316870565
    ), pGSK3B_N = c(0.0726318660370534, 0.0113934692941635, -0.0784493639363762, 
    -0.129201494480153, 0.157796847802845, 0.23002474684606, 
    -0.156189105610425, -0.139272331325838, 0.118225045060094, 
    0.100304800513178, -0.0300757618933809, 0.0285299986456296, 
    -0.0120541561865572, 0.0908216848045133, -0.0023908457607024, 
    0.0089400750177918), pPKCG_N = c(-0.286386712047411, 0.265957237376396, 
    0.0737964172058239, -0.0759384400199, -0.0177238455253068, 
    -0.261634570955355, -0.253741047251584, -0.256650485194398, 
    0.134270402692566, 0.120849091119421, -0.146949388514596, 
    -0.142381255596242, -0.324527167558674, 0.195095873727953, 
    0.208752130225386, 0.246345320116692), CDK5_N = c(0.0835756577065185, 
    0.00364250782584705, -0.0635878598042922, -0.0665527642492147, 
    0.0498548879577531, -0.0037462363944042, -0.0709716342392349, 
    -0.109665096982383, -0.00693856902849091, 0.0043142382793781, 
    -0.00379427922410826, 0.0233969910641444, -0.000723497291038827, 
    0.106033840892453, 0.029827781661049, 0.0297508490072604), 
    S6_N = c(0.168888926042562, 0.230803056253277, -0.154902829994192, 
    -0.269491504226569, 0.142290171760069, 0.252241256219668, 
    -0.23854742286132, -0.264415247456924, 0.290083441282089, 
    0.238143298906295, -0.198459186518937, -0.263240335960755, 
    0.238832926146062, 0.35530004861393, 0.427790444668465, 0.360513465094153
    ), ADARB1_N = c(0.224098318811728, 0.0338977810779033, 0.116024199822639, 
    -0.00457055801051897, 0.530704385640093, -0.178020136682188, 
    -0.113465216543545, -0.173452014027142, 0.00633272386184758, 
    -0.0237300986226981, 0.139970553648416, 0.00713778435199307, 
    0.356303393951797, 0.328108176871799, -0.103822560250247, 
    -0.160096407917707), RRP1_N = c(0.00159121579454942, -0.0299422881516384, 
    0.0173826784335047, 0.0386298578057867, -0.022152469642015, 
    0.0369774839239829, -0.0197907278638186, -0.0201116884888817, 
    -0.016726870724063, -0.0138128805216459, 0.00747529027834608, 
    0.0385018374429109, -0.0165448322480326, -0.00614007382478539, 
    -0.00733137421781927, 0.0183421735187617), BAX_N = c(0.0348507900184639, 
    -0.169715973558917, 0.0312101948023616, 0.0728175524004573, 
    0.179257945173096, -0.00628218585999311, -0.114699647957541, 
    -0.213302817321221, -0.0219721111119517, -0.0411959352332957, 
    0.0140823449452806, 0.00562779088047583, -0.0465748954281123, 
    0.166914376799791, 0.121181906942324, 0.0465930748380351), 
    ERBB4_N = c(0.226825268882082, -0.124939501170309, -0.0779332590062461, 
    -0.18657539448526, 0.186503290026721, -0.209722491963456, 
    -0.0376960514068148, 0.0222951541745705, -0.058799632488138, 
    -0.106621802599657, 0.037095159045507, -0.0713172478048624, 
    0.0826014680466721, 0.0644672868926184, -0.022902877277575, 
    0.0811348220744181), nNOS_N = c(-0.0597607386610167, 0.0694317666060796, 
    0.0267840157110256, -0.0466611419857235, -0.0427174888142891, 
    -0.312236651256378, -0.010954182164099, -0.152991551731999, 
    -0.0500742377998905, -0.112776761155327, -0.0702701990622843, 
    -0.158725995917858, -0.170582110044521, -0.195995554048211, 
    0.270601021309697, 0.164312802991015), Tau_N = c(-0.0295470448997678, 
    -0.0135843635099774, -0.0532058617661047, -0.0555870385379599, 
    0.0413976507530296, -0.134898190226349, -0.0588315550075754, 
    -0.0795207957893949, -0.00171411389248874, -0.0482028991095779, 
    -0.132181492884161, -0.16272346727488, 0.0684355887357164, 
    0.0845081538871629, 0.17928411442039, 0.399425311619017), 
    GFAP_N = c(0.1022369732202, -0.0375872399271431, 0.0389750353783662, 
    -0.0504675751546967, 0.0274358635290079, 0.1734228779599, 
    -0.0412006018348187, -0.0716080720004096, 0.00463136477041947, 
    0.0395185137074335, -0.0488608095557386, 0.133429595736969, 
    -0.0456410825935039, -0.0308800819276867, -0.0205041295367554, 
    0.00291773400108061), GluR3_N = c(-0.030610619693228, -0.0419884945813332, 
    -0.0215878967844794, 0.13788987742286, 0.0097421522245054, 
    -0.185481343626263, 0.039394235524668, -0.0423606094227236, 
    -0.0300386175931323, -0.0704781156851588, 0.149635559983053, 
    0.194784934048682, 0.0579351879333201, -0.029201096262343, 
    0.035471474252518, 0.0130390262499429), GluR4_N = c(-0.0645767955225773, 
    -0.051538941109314, -0.0313732251039657, -0.0141460065921882, 
    -0.00417582031288004, -0.029593478043205, -0.0337244128285424, 
    -0.0473718497413239, -0.0076614057457667, -0.0274641649555311, 
    0.0567450285050144, 0.131417882380042, 0.0167002653120917, 
    0.0102756570041332, 0.0589477012145904, 0.0282615479355968
    ), IL1B_N = c(0.0271273847003715, -0.105491449847318, 0.0437609140660753, 
    -0.100682647720751, -0.0220718458071589, -0.255060461104892, 
    0.136556106808522, 0.171611061468201, -0.107978458154497, 
    -0.138468912721386, 0.0906412612736424, 0.103367168201442, 
    -0.0471777535915392, -0.0996457367924041, -0.0253085398636734, 
    0.0972606458616279), P3525_N = c(0.282068129966564, -0.00165311433635766, 
    -0.0922619335624527, -0.153415327839175, 0.123335275814776, 
    -0.217141845924011, -0.0794347237762894, -0.0633312926140292, 
    -0.0550134841848069, -0.0335943662560428, -0.172561096964795, 
    -0.0591245566896425, -0.0903407471772672, 0.0672553394698634, 
    0.277963667780744, 0.280422376361652), pCASP9_N = c(-0.0809064432825608, 
    -0.0137019165208861, 0.177743120582825, -0.0475158803923548, 
    0.193740256728041, -0.234087587902465, -0.13810712700627, 
    -0.123144569174683, -0.159086554429722, -0.196839206663645, 
    0.272409729812092, 0.163528529740624, 0.094264422008515, 
    0.0323567060275672, 0.132123054461642, -0.0232714678908218
    ), PSD95_N = c(0.0540563342629853, -0.0442860567878406, 0.192681249153854, 
    -0.0499306400945902, -0.0256836260381356, -0.130320516544179, 
    -0.0318622026430037, -0.05550691698767, -0.0550237612521986, 
    -0.0975383913984803, 0.0610109420236561, -0.016528638117965, 
    -0.0355453200230897, 0.0361199546017388, -0.0438265148666351, 
    0.15961796487275), SNCA_N = c(0.10038812821577, -0.203187652543977, 
    0.132600250445984, 0.0870009029169576, -0.16121896139518, 
    0.00675222688338345, 0.201408060453561, 0.166171601944603, 
    -0.244202510820346, -0.184881118438059, 0.0158087569191595, 
    0.163733417301441, -0.19931602328197, -0.0822025824650802, 
    0.0270161636801945, -0.0311533368903992), Ubiquitin_N = c(0.113890598772724, 
    -0.0571595522614428, 0.251655448625955, 0.0290662757157521, 
    -0.113226757122626, -0.118822873950306, -0.0895156964787369, 
    -0.115101576386724, -0.0883300072975741, -0.0451690155410069, 
    0.0356232623609365, 0.10502000854939, -0.242738889727437, 
    -0.000642607498821009, 0.023342908881478, -0.000996135171924353
    ), pGSK3B_Tyr216_N = c(0.171426581336935, 0.21964402951554, 
    -0.146777292906524, -0.180066591627815, 0.0607373096178199, 
    -0.338285372919054, -0.192946966367207, -0.179745246639312, 
    -0.0202782074462171, -0.0754752662878523, -0.0458616948609926, 
    -0.0702022161357589, -0.0329854942199789, 0.103988666502327, 
    0.160536360262989, 0.130136693548004), SHH_N = c(0.167413839912217, 
    0.177150215231475, -0.11706030681231, -0.103724722509818, 
    -0.105962891517635, -0.163445660332417, 0.26057121922903, 
    0.323113244273389, -0.154575367677723, -0.203841975554592, 
    -0.196762498711561, -0.0810430316565208, -0.164628664080618, 
    -0.0670952384804719, 0.0701383687380666, 0.0664763199521191
    ), BAD_N = c(1.38627815493717e-17, 0.108885085055258, 1.38627815493717e-17, 
    0.204958164782363, -0.109706654809739, 1.38627815493717e-17, 
    -0.0384428632142642, 0.113022480455563, -0.0230560609956582, 
    0.00709971300305052, 0.0944175354012559, 0.258234547510358, 
    -0.172555989304076, -0.115571199147466, -0.0361880642339753, 
    0.0555296363853341), BCL2_N = c(0.174830527318015, -0.0351916650236411, 
    4.47594455930353e-17, 0.16122241936817, -0.153630588784925, 
    4.47594455930353e-17, 0.0259483341117695, 0.10217304978238, 
    -0.113426224559798, -0.0493655879422875, 4.47594455930353e-17, 
    4.47594455930353e-17, -0.176439561319639, 0.00332642384209326, 
    -0.112281307284837, 4.47594455930353e-17), pS6_N = c(0.0544957045743841, 
    -0.215498231280905, 0.176330539472927, -0.0180427806336791, 
    0.0405134698307664, -0.196511194503692, 0.0896380150212792, 
    -0.00178437398723737, -0.111094705650147, -0.164447287557879, 
    0.0171495879982054, 0.17357748138507, -0.0854290326165926, 
    -0.136862309389642, 0.0486149936008245, 0.0468734606012612
    ), pCFOS_N = c(-3.94541709971541e-17, 0.144688662108845, 
    -0.0523244997808654, 0.183632906884199, -0.0943286515483249, 
    -0.154870867441355, 0.0273962871834048, -0.0446413560661544, 
    -0.151142681858317, -0.142540841364996, -0.0409951996945863, 
    0.209594994520851, -0.07067492413067, -0.0951447007727713, 
    0.0510274910486943, -0.10813485862325), SYP_N = c(0.1699192032091, 
    -0.007408249850341, 0.105706192867166, 0.030169211570003, 
    0.264311270468507, -0.174104272666862, -0.0320510372603059, 
    -0.146577591364027, 0.0748281855773365, 0.0921704540339964, 
    0.125632959616699, 0.101821683371461, -0.0991623357830543, 
    0.24508774982114, -0.0514314977651764, -0.0356173972612358
    ), H3AcK18_N = c(0.00318526058246947, 0.030516867974744, 
    0.0458325444094067, 0.0823406614957822, 0.0655800040015427, 
    1.34928358031281e-17, -0.066090760307071, -0.0164952261270702, 
    0.0193438095162109, 0.0214199163861949, 1.34928358031281e-17, 
    1.34928358031281e-17, -0.18204363595328, 0.0122967495407723, 
    -0.0057641327038032, 0.315397204575443), EGR1_N = c(0.22091436521792, 
    -0.0418899558545117, 4.08083728048395e-18, 4.08083728048395e-18, 
    -0.132192787939268, 4.08083728048395e-18, 0.170088635236541, 
    0.14416021675064, -0.136632103055064, -0.105975572333308, 
    0.157046871143272, 0.390639305517813, -0.135156681648399, 
    -0.14858326296597, -0.0787741349821091, -0.00864723924102435
    ), H3MeK4_N = c(2.39945987461847e-17, 2.39945987461847e-17, 
    2.39945987461847e-17, 0.0613111993676987, -0.0735063751409676, 
    2.39945987461847e-17, -0.0518102234068636, -0.0134739460741966, 
    -0.0578126454640219, 0.0237615758984536, 2.39945987461847e-17, 
    2.39945987461847e-17, -0.176488012336739, -0.119630246017519, 
    -0.139100793400124, 0.159811180815282), CaNA_N = c(0.228323127723045, 
    0.156499372224674, -0.218869345925655, -0.347696517405393, 
    0.258547187716627, 0.0491641323435211, -0.275043873926982, 
    -0.280621847419711, 0.221404071790851, 0.213771806346338, 
    -0.138770962441139, -0.179432243201944, 0.104799593812621, 
    0.247597575511052, -0.0575169171888767, 0.0268368286591718
    ), class = c("c-CS-m", "c-CS-m", "c-SC-m", "c-SC-m", "c-CS-s", 
    "c-CS-s", "c-SC-s", "c-SC-s", "t-CS-m", "t-CS-m", "t-SC-m", 
    "t-SC-m", "t-CS-s", "t-CS-s", "t-SC-s", "t-SC-s")), row.names = c(NA, 
-16L), class = c("tbl_df", "tbl", "data.frame"))

my code:

# Splitting the data
trainX <- createDataPartition(np_2$class ,p=0.8,list=FALSE)
train <- np_2[trainX,]
test <- np_2[-trainX,]

Model 1:

svm1 <- svm(class~., data = train, type = "C", kernal="radial", 
            gamma=0.1, cost=10)

Model 2:

x <- subset(np_2, select = -class) 
y <- np_2$class
model <- svm(x, y, probability = TRUE)
pred_prob <- predict(model, x, decision.values = TRUE, probability = TRUE)

Error:

Error in svm.default(x, y, probability = TRUE) : 
  Need numeric dependent variable for regression.

CodePudding user response:

Here you go. Next time try to include the libraries:

Just transform your class to a factor. In that case, the svm will convert it to numeric for you:

np_2 <- transform(np_2, class = factor(class))
trainX <- caret::createDataPartition(np_2$class ,p=0.8,list=FALSE)
train <- np_2[trainX,]
test <- np_2[-trainX,]

e1071::svm(class~.,data =train, type = "C", kernal="radial",gamma=0.1,cost=10)

which outputs:

Call:
svm(formula = class ~ ., data = train, type = "C", kernal = "radial", gamma = 0.1, cost = 10)


Parameters:
   SVM-Type:  C-classification 
 SVM-Kernel:  radial 
       cost:  10 

Number of Support Vectors:  16
  • Related