r - Plot error SVM...min not meaningful for factors -


i trying train svm anomaly detection. this, created train_data , test_data using sourceip , protocol. when trying use plot function, gives me below error...

> plot(svmfit,testdat) error in summary.factor(c(7l, 7l, 7l, 7l, 7l, 7l, 7l, 7l, 7l, 7l, 7l,  :    min not meaningful factors 

how can rid of error..?

following lines of commands in external file

    train_data=read.csv("packetcapture_training.csv")     #read source ip , protocol       xtrain=train_data[4:23,c(3,5)]     ytrain=c(rep(-1,10),rep(1,10))     dat=data.frame(x=xtrain,y=as.factor(ytrain))     library("e1071")     svmfit=svm(y~.,data=dat,kernel="radial",cost=10,scale=false)     summary(svmfit)     test_data=read.csv("packetcapture_testing.csv")     #read source ip , protocol     xtest=test_data[371:390,c(3,5)]     ytest=c(rep(1,10),rep(-1,10))     testdat=data.frame(x=xtest,y=as.factor(ytest))     plot(svmfit,testdat)          > dat                    x.source x.protocol  y 1  fe80::a00:27ff:feee:7ec6     icmpv6 -1 2  fe80::a00:27ff:feee:7ec6     icmpv6 -1 3  fe80::a00:27ff:feee:7ec6     icmpv6 -1 4               172.16.11.1        tcp -1 5             192.168.2.101        tcp -1 6               172.16.11.1        tcp -1 7               172.16.11.1        tcp -1 8               172.16.11.1        tcp -1 9             192.168.2.101        tcp -1 10            192.168.2.101        tcp -1 11              172.16.11.1        tcp  1 12              172.16.11.1        tcp  1 13              172.16.11.1        tcp  1 14            192.168.2.101        tcp  1 15              172.16.11.1        tcp  1 16            192.168.2.101        tcp  1 17              172.16.11.1        tcp  1 18              172.16.11.1        tcp  1 19            192.168.2.101      sshv2  1 20              172.16.11.1        tcp  1  > dput(head(dat,4)) structure(list(x.source = structure(c(6l, 6l, 6l, 1l), .label = c("172.16.11.1",  "192.168.2.100", "192.168.2.101", "cadmusco_8b:7b:80", "cadmusco_ee:7e:c6",  "fe80::a00:27ff:feee:7ec6"), class = "factor"), x.protocol = structure(c(5l,  5l, 5l, 7l), .label = c("arp", "dns", "http", "icmp", "icmpv6",  "sshv2", "tcp", "udp"), class = "factor"), y = structure(c(1l,  1l, 1l, 1l), .label = c("-1", "1"), class = "factor")), .names = c("x.source",  "x.protocol", "y"), row.names = c(na, 4l), class = "data.frame")  > testdat          x.source x.protocol  y 371   172.16.11.1        tcp  1 372   172.16.11.1        tcp  1 373   172.16.11.1        tcp  1 374   172.16.11.1        tcp  1 375   172.16.11.1        tcp  1 376   172.16.11.1        tcp  1 377   172.16.11.1        tcp  1 378   172.16.11.1        tcp  1 379   172.16.11.1        tcp  1 380   172.16.11.1        tcp  1 381   172.16.11.1        tcp -1 382   172.16.11.1        tcp -1 383   172.16.11.1        tcp -1 384   172.16.11.1        tcp -1 385   172.16.11.1        tcp -1 386   172.16.11.1        tcp -1 387   172.16.11.1        tcp -1 388   172.16.11.1        tcp -1 389 192.168.2.101      sshv2 -1 390 192.168.2.101     icmpv6 -1   > dput(head(testdat,4)) structure(list(x.source = structure(c(1l, 1l, 1l, 1l), .label = c("172.16.11.1",  "192.168.2.100", "192.168.2.101", "cadmusco_8b:7b:80", "cadmusco_ee:7e:c6",  "fe80::a00:27ff:feee:7ec6"), class = "factor"), x.protocol = structure(c(7l,  7l, 7l, 7l), .label = c("arp", "dns", "http", "icmp", "icmpv6",  "sshv2", "tcp", "udp"), class = "factor"), y = structure(c(2l,  2l, 2l, 2l), .label = c("-1", "1"), class = "factor")), .names = c("x.source",  "x.protocol", "y"), row.names = 371:374, class = "data.frame") 

the plot.svm function in library("e1071") apparently plot continuous predictors. because model uses 2 categorical predictors, getting error. know kind of visualization expecting?

in examples on page, shows

data(cats, package = "mass") m <- svm(sex~., data = cats) plot(m, cats) 

and there can spread out points along range , cutting can happen @ meaningful break point. categorical predictors, not ordered there's no clear way plot them in similar way really.


Comments

Popular posts from this blog

android - Automated my builds -

how to proxy from https to http with lighttpd -

python - Flask migration error -