[R] Progress bar in random forest model

Mohammad Tanvir Ahamed mashranga at yahoo.com
Wed Sep 23 20:51:12 CEST 2015


Hi , 

I am using randomForest model in R .

For large number of tree my program takes long time to complete . 

In "randomForest" function i can use "do.trace=TRUE" to see the real time progress .  Sample out put in real time on R console is as follows

ntree      OOB      1      2      3      4      5      6      7      8      9 
100:   2.31%  7.14%  2.08%  0.00%  2.25% 10.81%  0.90%  0.00%  0.00%  1.72% 
200:   1.95%  7.14%  2.08%  0.00%  2.25%  8.11%  0.00%  0.00%  0.00%  1.72% 
300:   1.78%  7.14%  2.08%  0.00%  1.69%  8.11%  0.00%  0.00%  0.00%  1.72% 
400:   1.95%  7.14%  2.08%  0.00%  1.69%  8.11%  0.00%  0.00%  0.00%  3.45% 
500:   1.78%  7.14%  2.08%  0.00%  1.69%  8.11%  0.00%  0.00%  0.00%  1.72% 
600:   1.78%  7.14%  2.08%  0.00%  1.69%  8.11%  0.00%  0.00%  0.00%  1.72% 
700:   1.78%  7.14%  2.08%  0.00%  1.69%  8.11%  0.00%  0.00%  0.00%  1.72% 
800:   1.78%  7.14%  2.08%  0.00%  1.69%  8.11%  0.00%  0.00%  0.00%  1.72% 
900:   1.78%  7.14%  2.08%  0.00%  1.69%  8.11%  0.00%  0.00%  0.00%  1.72% 
1000:   1.78%  7.14%  2.08%  0.00%  1.69%  8.11%  0.00%  0.00%  0.00%  1.72%

The first row (100: 2.31% ....) comes first. After 1 second it comes 2nd row and so on. 
Now i like to modify this out put . 

like, when 1st row will come , i like to grab only 100 form the whole line and show only 100 on R console instead of showing whole line. The same this will happen for rest of the row.

[ i tried sink(). but it will not work as sink write the complete output to out file ]

[I searched for do.trace option in randomForest function. but i lost myself  as i feel it call come C program. not sure but could not figured it out]


In general, i like to grab the real time output on R console.

I will be very grateful if any one please help me with . 

Thank you    

 
Tanvir Ahamed 
Göteborg, Sweden  |  mashranga at yahoo.com



More information about the R-help mailing list