I want to know whether we can calculate accuracy for principal component regression in R. The Target variable has only two values 0 or 1. I tried factoring training $ Target and validation $ Target variable but it says col(y) must be numeric. So leaving it as is.
pcr.fit <- pcr(training$Target~.,data=training, validation="CV")
summary(pcr.fit)
validationplot(pcr.fit)
coefplot(pcr.fit)
pcr.predictions <- predict(pcr.fit, newdata, ncomp = 3, type="response")
conf <- confusionMatrix(pcr.predictions, validation$Target)
Error in confusionMatrix.default(pcr.predictions, validation$Target) :
the data cannot have more levels than the reference
I also tried changing type to "class" but later came to know that Error in match.arg(type) : 'arg' should be one of “response”, “scores”
caretormlrto take care of these cross-validation issues in a structured and coherent manner. That said it is unclear if the target value is a label or actually numeric... I believe you want to ultimately classify things but in that casepcris not the proper tool as it works only for regression. – usεr11852 Apr 02 '18 at 13:07