party ライブラリの cforest 関数を使用して、機能の重要度を測定したいと考えています。
私の出力変数には、クラス 0 に 2000 サンプル、クラス 1 に 100 サンプルなどがあります。
クラスの不均衡によるバイアスを回避する良い方法は、クラス 1 の要素の数がクラス 0 の要素の数と同じになるように、サブサンプルを使用してフォレストの各ツリーをトレーニングすることだと思います。
とにかくそれを行うことはありますか?私は次のようなオプションを考えていますn_samples = c(20, 20)
編集:コードの例
> iris.cf <- cforest(Species ~ ., data = iris,
+ control = cforest_unbiased(mtry = 2)) #<--- Here I would like to train the forest using a balanced subsample of the data
> varimp(object = iris.cf)
Sepal.Length Sepal.Width Petal.Length Petal.Width
0.048981818 0.002254545 0.305818182 0.271163636
>
編集: 多分私の質問は十分に明確ではありません. ランダム フォレストは一連の決定木です。一般に、デシジョン ツリーは、データのランダムなサブサンプルのみを使用して構築されます。使用するサブサンプルの要素数がクラス 1 とクラス 0 で同じであることを望みます。
編集:私が探している関数は、randomForest パッケージで確実に利用できます
sampsize
Size(s) of sample to draw. For classification, if sampsize is a vector of the length the number of strata, then sampling is stratified by strata, and the elements of sampsize indicate the numbers to be drawn from the strata.
パーティーパッケージにも同じものが必要です。入手する方法はありますか?