Random Forest in R [set.seed()/parameters/confusion matrix] So, I have a few questions concerning random Forests (mainly in R):


*

*How ntree affects Random Forests in general? Will we get more precise "OOB error" (more trees -> bigger possibility that OOB sample will be part of a test set for more trees -> hence, precise OOB error?)?

*How set.seed() helps randomness for RFs? When we do sampling with replacement I'm thinking that by using the same seed (ex. set.seed(1234)) we will draw same rows for each forest? That is, if we used first 10 rows on tree_1, in random forest_1 then we will use the same rows in tree_1 of  random_forest_2, or random_forest_3 etc.

*Why changing the order of features “improves” a bit OOB error rate, and overall class.error? (using the same seed)

*Speaking of R, how is confusion matrix made for Random Forest? Do we first train the model, and then we put all the data points in pre-trained RF so we can obtain TruePositives etc. by counting them.


PS. I'm currently using RFs mainly for EDA!
 A: 
  
*
  
*How ntree affects Random Forests in general? Will we get more precise "OOB error" (more trees -> bigger possibility that OOB sample
  will be part of a test set for more trees -> hence, precise OOB
  error?)?
  

This is simple: the more trees, the better, where you should use something like 100, 250, or more trees if you can afford it.


  
*How set.seed() helps randomness for RFs? When we do sampling with replacement I'm thinking that by using the same seed (ex.
  set.seed(1234)) we will draw same rows for each forest? That is, if we
  used first 10 rows on tree_1, in random forest_1 then we will use the
  same rows in tree_1 of  random_forest_2, or random_forest_3 etc.
  

Setting seed for random number generator makes the results reproducible. So if you use, and record the seed, then when running the algorithm next time with the same data and same hyperparameters, it will give you exactly the same results. Of course, we are talking here about setting seed before running the whole random forest algorithm, if you'd set the seed to the same value before training each of the trees within the random forest, all the trees would be identical, what would make them useless, since the algorithm would work not better then single decision tree.


  
*Why changing the order of features “improves” a bit OOB error rate, and overall class.error? (using the same seed)
  

It does not. If this is something that you observed, this must have happened by chance, or may suggest that there is some kind of bug in the code. In the Collinearity of features and random forest thread you can find more details that should shed some light on this.


  
*Speaking of R, how is confusion matrix made for Random Forest? Do we first train the model, and then we put all the data points in
  pre-trained RF so we can obtain TruePositives etc. by counting them.
  

Yes, it's exactly the same as with any other algorithm: you train it, then you plug-in the data and look at the predictions, to compare them with the true labels and calculate the metrics.
You seem to have many questions on this topic, Q&A sites like this are not best suited for explaining such cases in detail (you usually can expect rather brief and focused answers). I'd recommend you to start with a handbook, for example the great and freely available ISL and ESL. Finally, next time please try asking one question per thread, follow the be specific rule.
