SVM error

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

SVM error

pedrosmarques

Hi all,

I'm having this error, since I'm working with a data matrix I don't understand what's happening; I've tried several ways to solve this, even working with sparse matrix, but nothing seems to solve it, I've also tried svm (with a simple matrix 3*3 and still got the same error.

> dados<-read.table("b.txt",sep="",nrows=30000)
> dados1<-as.matrix(dados[,-1],nrows=30000,ncol=13,type=numeric)
> dados2<-as.vector(dados[,1])
> model<-svm(scale=TRUE,type=C,dados[,-1],y=dados[,1],kernel=RBF)
Error in as.character(x) : cannot coerce to vector
> model<-svm(scale=TRUE,type=C,dados1,y=dados2,kernel=RBF)
Error in as.character(x) : cannot coerce to vector

Best regards,

Pedro Marques

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: SVM error

Uwe Ligges
Are we talking about package "e1071"?


[hidden email] wrote:
> Hi all,
>
> I'm having this error, since I'm working with a data matrix I don't understand what's happening; I've tried several ways to solve this, even working with sparse matrix, but nothing seems to solve it, I've also tried svm (with a simple matrix 3*3 and still got the same error.
>
>> dados<-read.table("b.txt",sep="",nrows=30000)


We cannot reproduce: We do not have "b.txt". See the posting guide.



>> dados1<-as.matrix(dados[,-1],nrows=30000,ncol=13,type=numeric)

Why do you specify nrows, ncol and type=numeric?


>> dados2<-as.vector(dados[,1])

Well, as.vector() strips attributes, particularly it removes the
"factor" attributes!


>> model<-svm(scale=TRUE,type=C,dados[,-1],y=dados[,1],kernel=RBF)

type=C and kernel=RBF cannot make sense, I guess you mean

     model <- svm(x=dados[,-1], y=dados[,1], scale=TRUE,
                  type="C", kernel="RBF")


> Error in as.character(x) : cannot coerce to vector
>> model<-svm(scale=TRUE,type=C,dados1,y=dados2,kernel=RBF)

Same as before.

Please do read "An Introduction to R" - particularly on how to specify
arguments in function calls before proceeding.

Uwe Ligges



> Error in as.character(x) : cannot coerce to vector
>
> Best regards,
>
> Pedro Marques
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.