Please post in plain text, and supply a reproducible example (that
includes sample data, preferably using the dput function).
The below code obtains repeatable random number sequences in each pass
through the loop, as confirmed by the first value in each sequence.
##
a <- 0
##
## For loop to test the various combinations of ntree and mtry
for ( j in 1:8 ) {
for ( i in 1:3 ) {
b <- 1968 + a
set.seed( b )
cat( i, " ", j, " ", runif( 1 ), "\n" )
}
}
On Thu, 9 Jul 2015, Joao Carreiras wrote:
Dear forum members,
?I wrote a piece of code to test various combinations of mtry and ntree, so
that the best combination (in terms of mse?) could be used. Before each
randomForest command I included a set.seed() command, so that I can keep
track of the seed number and replicate the results. However, when I run the
randomForest command again with the seed number corresponding to the best
combination I get a different mse. Any suggestions?
Thanks and best wishes
Joao
------------
## Define the number of trees to test
nt <- c(100, 200, 300, 400, 500, 700, 900, 1000)
## Define the number of variables to be randomly selected at each node
mt <- c(1, 2, 3)
##
a <- 0
##
## For loop to test the various combinations of ntree and mtry
for (j in 1:8)
for (i in 1:3)
? ?
{
b <- 1968 + a
set.seed(b)
HH <- randomForest(HH_MEAN ~ ASF + PALU + FC
??
,
??
data = model.data,
ntree = nt[j],
mtry = mt[i],
replace = T,
? ?
? }?
?----------------?
??
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.