Run Code  | Code Wall  | Users  | Misc  | Feedback  | About  | Login  | Theme  | Privacy 

Random Forest Example

Language: Editor: Layout:
+ ] Show input
Absolute running time: 0.74 sec, cpu time: 0.52 sec, memory peak: 36 Mb, absolute service time: 0,76 sec 
edit mode |  history  | discussion
Error(s), warning(s):
randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.
Warning message:
In randomForest.default(x, y, mtry = mtryCur, ntree = ntreeTry,  :
  invalid mtry: reset to within valid range

'data.frame':	150 obs. of  5 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa
6          5.4         3.9          1.7         0.4  setosa
            
             setosa versicolor virginica
  setosa         39          0         0
  versicolor      0         34         2
  virginica       0          2        29

Call:
 randomForest(formula = Species ~ ., data = TrainData, ntree = 100,      proximity = TRUE) 
               Type of random forest: classification
                     Number of trees: 100
No. of variables tried at each split: 2

        OOB estimate of  error rate: 3.77%
Confusion matrix:
           setosa versicolor virginica class.error
setosa         39          0         0  0.00000000
versicolor      0         34         2  0.05555556
virginica       0          2        29  0.06451613
            
Test         setosa versicolor virginica
  setosa         11          0         0
  versicolor      0         14         4
  virginica       0          0        15
mtry = 2  OOB error = 4.67% 
Searching left ...
mtry = 4 	OOB error = 4% 
0.1428571 0.05 
mtry = 8 	OOB error = 4% 
0 0.05 
Searching right ...
mtry = 1 	OOB error = 5.33% 
-0.3333333 0.05 
      mtry   OOBError
1.OOB    1 0.05333333
2.OOB    2 0.04666667
4.OOB    4 0.04000000
8.OOB    8 0.04000000