[R] Error in roc.default(response, predictor, auc = TRUE, ...) : No valid data provided.

Allan Tanaka allantanaka11 at yahoo.com
Thu Mar 16 16:38:16 CET 2017


Check my fitted dimension:str(predict(mod, Test1)) 
 Named num [1:2131] 402 2346 1995 2205 2895 ... - attr(*, "names")= chr [1:2131] "1" "2" "4" "6" ...

So i want to see AUC score for my model being applied into Test1data after having splitting total data (Train) into Train 1 and Test 1, but i get the following error:Error in roc.default(response, predictor, auc = TRUE, ...) :    No valid data provided.

Even trying this code also gives a malfunction:error<-sqrt((sum((Test1$Item_Outlet_Sales-preds)^2))/nrow(Test1))  
Error in Test1$Item_Outlet_Sales - preds :   non-numeric argument to binary operator===================================================
Here is the code:
set.seed(1234)
split <- sample(1:nrow(Train),size=floor((nrow(Train)/4)*3)) Train1 <- Train[(split),]Test1 <-  Train[-split,]outcomeName='Item_Outlet_Sales'predictorNames <- setdiff(names(Train1), outcomeName)mod <- lm(Item_Outlet_Sales ~ ., data=Train1)preds <- predict(mod, Test1[,predictorNames], se.fit = TRUE)print(auc(Test1[,outcomeName], preds$mod))
	[[alternative HTML version deleted]]



More information about the R-help mailing list