I have a datasets composed like this:
library(caret)
data <- iris
train <- data [1:75,]
test <- data[76:150,]
So, I have 3 classes in total but:
- Train: setosa and versicolor
- Test: versicolor and virginica
I tryed to set a decision tree, but obviusly it doesn't work because train and test haven't the same classes. My R code is:
trainctrl <- trainControl(method = "cv", number = 5, verboseIter = FALSE)
dt.model <- train(Species~., data=train, method = "rpart",
tuneLength = 10,
preProcess = c("center", "scale"),
trControl = trainctrl)
test$prediction <-predict(dt.model, test)
Is there a model that if in the test meets a virginica class flower is able to tell me that it is another species? In other words, I want a model that can tell me that that flower is completely different from the ones he trained on. Is it possible?