R Language                
            機械学習
        
        
            
    サーチ…
ランダムフォレストモデルの作成
機械学習アルゴリズムの一例は、ランダムフォレストアルゴリズムである(Breiman、L.(2001)、Random Forests、 Machine Learning 45(5) 、p。5-32)。このアルゴリズムは、 randomForestパッケージ内のBreimanの元のFortran実装に従ってRで実装されてrandomForestます。 
クラスター変数をfactorとして準備することにより、R内でランダムフォレストの分類子オブジェクトを作成することができます。これは、すでにirisデータセットで明らかです。したがって、次の方法で簡単にランダムフォレストを作成できます。 
library(randomForest)
rf <- randomForest(x = iris[, 1:4], 
                   y = iris$Species, 
                   ntree = 500, 
                   do.trace = 100)
rf
# Call:
#   randomForest(x = iris[, 1:4], y = iris$Species, ntree = 500,      do.trace = 100) 
# Type of random forest: classification
# Number of trees: 500
# No. of variables tried at each split: 2
# 
# OOB estimate of  error rate: 4%
# Confusion matrix:
#   setosa versicolor virginica class.error
# setosa         50          0         0        0.00
# versicolor      0         47         3        0.06
# virginica       0          3        47        0.06
| パラメーター | 説明 | 
|---|---|
| バツ | クラスの記述変数を保持するデータフレーム | 
| y | 個々の観察のクラス。このベクトルが factor場合は、分類モデルが作成され、そうでない場合は、回帰モデルが作成されます。 | 
| ntree | 作成された個々のCARTツリーの数 | 
| do.trace | i 番目のステップごとに、全体的なエラーと各クラスのエラーが返されます | 
Modified text is an extract of the original Stack Overflow Documentation
        ライセンスを受けた CC BY-SA 3.0
        所属していない Stack Overflow