Hi,
On Thu, May 13, 2010 at 3:54 PM, jparga <argajuan at yahoo.com.ar>
wrote:>
> Hello, I hope you can help me!
> I`m trying to tune svm parameters: cost and gamma for a landsat image
> classification, but I get an error and I can't understand it.
> I write this:
>> tune(svm, Class~., data = mdt01bis, ranges = list(gamma = 2^(-15:3),
cost
>> = 2^(-5:15)))
> and R gives:
> Error en predict.svm(model, if (!is.null(validation.x)) validation.x else
if
> (useFormula) data[-train.ind[[sample]], ?:
> ?test data does not match model !
>
> The matrix is as follows, with 720 rows and 4 categories in column Class
> B1 ? ? ? B2 ? ? ? B3 ? ? ? B4 ? ? ? B5 ? ? ? B6 ? ? ? Class
> ?[1,] "0.0450" "0.0599" "0.1169"
"0.1820" "0.3040" "0.2826" "CV"
> ?[2,] "0.0481" "0.0630" "0.1222"
"0.1854" "0.3040" "0.2891" "CV"
> ?[3,] "0.0497" "0.0630" "0.1329"
"0.1988" "0.2929" "0.2794" "CV"
> ?[4,] "0.0450" "0.0567" "0.1196"
"0.1854" "0.2973" "0.2859" "CV"
>
> and the svm:
>> svm(Class~., data=mdt01bis, method="C-classification",
kernel="radial",
>> cost=10, gamma=0.1)
> works ok.
> Could you please tell me what is wrong?
I'm not really sure, but the first red flag is that your numbers are
stored as characters (B1, B2, etc. are strings)
Also the formula interface expects a data.frame (an object which can
have mixed column types) and not a matrix (an object that can only
contain one type).
Since one of your columns contains "CV", and you're trying to
horseshoe all of you data into a matrix, perhaps all your numerical
values are being upcast to characters, which is subsequently messing
something up.
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact