Skip to content

Commit

Permalink
Fix incorrect sampling in bagged avNNet.
Browse files Browse the repository at this point in the history
avNNet with bag = TRUE currently samples without replacement. This therefore just reorders the rows.
avNNet now samples WITH replacement therefore giving proper bagging.
  • Loading branch information
timcdlucas committed May 25, 2015
1 parent c96fa7f commit f30672b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/caret/R/avNNet.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ avNNet.default <- function(x, y, repeats = 5, bag = FALSE, allowParallel = TRUE,
{
if(theDots$trace) cat("\nFitting Repeat", i, "\n\n")
} else cat("Fitting Repeat", i, "\n\n")
if(bag) ind <- sample(1:nrow(x))
if(bag) ind <- sample(1:nrow(x), replace = TRUE)
thisMod <- if(is.null(classLev)) nnet::nnet(x[ind,,drop = FALSE], y[ind], ...) else nnet::nnet(x[ind,,drop = FALSE], y[ind,], ...)
thisMod$lev <- classLev
thisMod
Expand Down

0 comments on commit f30672b

Please sign in to comment.