7.18 ランダム・フォレスト・モデル
ore.odmRF
クラスは、分類のためのアンサンブル学習手法を提供するデータベース内のランダム・フォレスト(RF)モデルを作成します。
ランダム・フォレスト・アルゴリズムは、バギングと変数のランダム選択の概念を組み合せることにより、デシジョン・ツリーの一般的な問題であるオーバーフィットを回避しながら、分散が制御されたデシジョン・ツリーの集合を生成します。
ランダム・フォレスト・モデルの設定
次の表に、ランダム・フォレスト・モデルに適用される設定を示します。
表7-19 ランダム・フォレスト・モデルの設定
設定名 | 設定値 | 説明 |
---|---|---|
|
|
ノードでの分割を選択する際に考慮する列のランダムなサブセットのサイズ。各ノードで、プールのサイズは同じですが、特定の候補列が変更されます。デフォルトは、モデル・シグネチャの列の半分です。特殊な値である |
|
|
フォレスト内のツリーの数 デフォルトは |
|
|
個々のツリーの作成で使用するためにランダムにサンプリングされるトレーニング・データの割合。デフォルトは、トレーニング・データ内の行数の半分です。 |
例7-21 ore.odmRF関数の使用方法
この例では、データ・フレームiris:を一時データベース表IRISにプッシュし、ランダム・フォレスト・モデルを作成します。
# Turn off row ordering warnings
options(ore.warn.order=FALSE)
# Create the a temporary OML4R proxy object IRIS.
IRIS <- ore.push(iris)
# Create an RF model object. Fit the RF model according to the data and setting parameters.
mod.rf <- ore.odmRF(Species ~ ., IRIS,
odm.settings = list(tree_impurity_metric = 'TREE_IMPURITY_ENTROPY',
tree_term_max_depth = 5,
tree_term_minrec_split = 5,
tree_term_minpct_split = 2,
tree_term_minrec_node = 5,
tree_term_minpct_node = 0.05))
# Show the model summary and attribute importance.
summary(mod.rf)
importance(mod.rf)
# Use the model to make predictions on the input data.
pred.rf <- predict(mod.rf, IRIS, supplemental.cols="Species")
# Generate a confusion matrix.
with(pred.rf, table(Species, PREDICTION))
この例のリスト
Call: ore.odmRF(formula = Species ~ ., data = IRIS, odm.settings = list(tree_impurity_metric = "TREE_IMPURITY_ENTROPY", tree_term_max_depth = 5, tree_term_minrec_split = 5, tree_term_minpct_split = 2, tree_term_minrec_node = 5, tree_term_minpct_node = 0.05))
Settings:
value
clas.max.sup.bins 32
clas.weights.balanced OFF
odms.details odms.enable
odms.missing.value.treatment odms.missing.value.auto
odms.random.seed 0
odms.sampling odms.sampling.disable
prep.auto ON
rfor.num.trees 20
rfor.sampling.ratio .5
impurity.metric impurity.entropy
term.max.depth 5
term.minpct.node 0.05
term.minpct.split 2
term.minrec.node 5
term.minrec.split 5
Importance:
ATTRIBUTE_NAME ATTRIBUTE_SUBNAME ATTRIBUTE_IMPORTANCE
1 Petal.Length <NA> 0.60890776
2 Petal.Width <NA> 0.53412466
3 Sepal.Length <NA> 0.23343292
4 Sepal.Width <NA> 0.06182114
表7-20 data.frame: 4 x 3
ATTRIBUTE_NAME | ATTRIBUTE_SUBNAME | ATTRIBUTE_IMPORTANCE |
---|---|---|
<chr> | <chr> | <dbl> |
Petal.Length | NA | 0.60890776 |
Petal.Width | NA | 0.53412466 |
Sepal.Length | NA | 0.23343292 |
Sepal.Width | NA | 0.06182114 |