Random-Forest-Klassifikation

Auch die Random-Forest-Methode lässt sich wahlweise auf Regressions- oder Klassifikationsprobleme anwenden. Für unsere SpamBase-Daten könnte das so aussehen:

> library(randomForest)
randomForest 4.5-36
Type rfNews() to see new features/changes/bug fixes.
>
> (Spam.randfor <- randomForest(ist.Spam ~ ., data = SpamBase.Training))

Call:
 randomForest(formula = ist.Spam ~ ., data = SpamBase.Training)
               Type of random forest: classification
                     Number of trees: 500
No. of variables tried at each split: 7

        OOB estimate of error rate: 5.06%
Confusion matrix:
       Ja Nein class.error
Ja   1172   97  0.07643814
Nein   66 1885  0.03382881

Achten Sie auf die Konfusionsmatrix, dort wird ausgewiesen, wie gut das Random-Forest-Modell die Trainingsdaten ...

Get R in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.