how to obtain predicted labels for test data using "kerne lpls"
You need to do some extra work if you want to do classification with a regression method. One simple way to do classification with PLS is to code the classes as 0s and 1s (assuming there are only two classes) or -1s and 1s, fit the model, then threshold the prediction; e.g., those with predicted values < 0.5 (in the 0/1 coding) get labeled as 0s. There's a predict() method for mvr objects, and that's what you need to use to get prediction on test set. There's one more complication: The CV done internal to mvr is optimizing the MSE (because it rightly thinks it has a regression problem), but that will almost certainly not be the thing to do for classification. You have two choices: Do your own CV, or modify code in pls.pcr to do the "right" CV when given classification data. You might want to look at the `gpls' package, which started out as part of BioConductor, then was made available on CRAN, but now seem to have move back to BioConductor. It treats classification problems in a more `natural' way. HTH, Andy
From: Huh, Seungho Dear members, My name is Seungho Huh. I am a statistician who tries to use the Kernel PLS method in a classification problem. I am sending this email to ask you something about the "kernelpls" function in R (pls.pcr package). I would like to obtain the predicted Y values for test data, using the Kernel PLS method. Let's take the example in the R help:
data(NIR) attach(NIR) NIR.kernelpls <- mvr(Xtrain, Ytrain, 1:6, validation = "CV",
method="kernelPLS")
How can we get the predicted Y values ("Ypred") for Xtest in
this case?
As far as I checked, there is no parameter to specify the test data in
"mvr" or "pls". I, therefore, thought about the "kernelpls"
function as
follows:
Kernelpls(Xtrain, Ytrain, ncomp = 21, Xtest)
Is this the correct way of getting Ypred for Xtest? I am afraid that it says in the help of "kernelpls", "this function should not be called directly, but through the generic pls function with the argument method="kernel" (default)." I would really appreciate it if you can give some advice on this. Thanks a lot for your time. Seungho Huh, Ph.D. Research Statistician RTI International North Carolina, USA [[alternative HTML version deleted]]
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html