I am trying to generate a model via caret package and I get some warnings which I cannot explain. Just to make my post reproductive I use as data frame the iris set.

con = trainControl(method="cv", number=3)
for_train = createDataPartition(df$Sepal.Length, p=.66, list=FALSE) 
model = train(Sepal.Length ~., data = train, method = "ANFIS", trControl = con)

with the above code I get 7 Warnings :

In validate.params(object, newdata) :
  There are your newdata which are out of the specified range


What exactly are the warning messages?

Are these warnings a sign that I did not built my model correctly?


While I was waiting for a help about the warnings I tried to generate the model without the caret package, with the use of the frbs:

train <- df[1 : 100, ]
test <- df[101 : 150, 1 : 3]
real.val <- matrix(df[101 : 150, 4], ncol = 1)


method.type <- "ANFIS"
control <- list(num.labels = 3, max.iter = 10, step.size = 0.01, type.tnorm = "MIN", type.snorm = "MAX", type.implication.func = "ZADEH", name = "iris")

my_object <- frbs.learn(train, my_range, method.type, control)
test_pr <- predict(my_object, test)

But still I get the same warnings and the test_pr is characterized by only only value.


These warnings are not from the caret package, but come from the frbs. If range.data is not given, it is calculated on the data coming into frbs.learn. For ANSI it is calculated as follows:

 dt.min <- matrix(do.call(pmin, lapply(1:nrow(data.train), 
        function(i) data.train[i, ])), nrow = 1)
 dt.max <- matrix(do.call(pmax, lapply(1:nrow(data.train), 
        function(i) data.train[i, ])), nrow = 1)

 range.data <- rbind(dt.min, dt.max)

With the 3 fold cv, you can have data points which fall outside dt.min / dt.max. That is the error / warning you get.

Edit: Looking into the documentation of fbrs, they mention the following:

Range of data could be defined or omitted. If it is omitted, frbswill calculate minimum and maximum of training data as the range. But, we recommend this parameter should be defined to avoid some data out of range, especially when performing predicting phase.

Looking into the examples and running a few tests, the range should be defined based on the full input data, not on the training data.

For the iris data set: range_data_input <- matrix(apply(iris[, 1:4], 2, range), nrow = 2)

  • $\begingroup$ Thank you for your response. I edited my question and as you can see the warning (you are right, is associated with the frbs) is still here despite the fact that I used the range. $\endgroup$ – geo_dd Sep 28 '16 at 9:29
  • $\begingroup$ @geo_dd, See edit in my answer. $\endgroup$ – phiver Sep 28 '16 at 11:25
  • $\begingroup$ Thank you! The range of the entire data set was the key. $\endgroup$ – geo_dd Sep 28 '16 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.