0

I have a scenario where some of the values for predictors are not present in the train dataset, but are present in the test dataset. How do we handle this in regression?

Here is what I have tried:

f1: Test dataset s1: Train dataset

f1[,c(328:1364)] <- sapply(f1[,c(328:1364)],as.character) 

lapply(c(328:1364),function(x) {
y <- x+14
f1[,x][which(!(f1[,x] %in% s1[,y]))] <- ""
})

While this executes successfully, the values in Test are still retained. Please advise.

Thanks, Sam

Sam
  • 1

1 Answers1

0

I used for loop and it worked.

for(x in 328:1364)
{
y <- x+14
f1[,x][which(!(f1[,x] %in% s1[,y]))] <- ""
}
Sam
  • 1