'NA impact in Caret Train
Following the example reported in the link below I have the following error:
Using nnet for prediction, am i doing it right?
Error in na.fail.default(list(y = c(0, 0.0998334166468282, 0.198669330795061, : missing values in object
To solve this error I use the condition na.action = na.omit
#Fit model
model <- train(y ~ x1 + x2, te, method='nnet', linout=TRUE, trace = FALSE,
#Grid of tuning parameters to try:
tuneGrid=expand.grid(.size=c(1,5,10),.decay=c(0,0.001,0.1)),
na.action = na.omit)
ps <- predict(model, te)
is.na(te)
nrow(te)
nrow(ps)
Is this condition the only way to proceed?
In fact the consequence is that the number of rows of the ps is different to the number of ps data.
Solution 1:[1]
Please try again executing the same above code by removing steps_per_epoch and validation_steps from model.fit:
model.fit(training_set,
#steps_per_epoch = 10,
epochs = 25,
validation_data = val_set,
# validation_steps = 4
)
Steps_per_epoch and validation_steps are not correct.
Removing these from model will itself count the steps_per_epoch as per given images_count and batch_size. Check this similar answer for reference.
As from warning, it shows Model.fit_generator is deprecated. You can use model.fit instead to remove the warning. Please let us know if the issue still persists.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TFer2 |
