1

キャレットを使用してトレーニング用のパラメーターのグリッドを作成しようとすると、さまざまなエラーが発生します。

> my_grid <- createGrid("rf")
Error in if (p <= len) { : argument is of length zero

> my_grid <- createGrid("rf", 4)
Error in if (p <= len) { : argument is of length zero

> my_grid <- createGrid("rf", len=4)                                        
Error in if (p <= len) { : argument is of length zero

createGrid のドキュメントには次のように書かれています。

This function creates a data frame that contains a grid of
     complexity parameters specific methods.
Usage:
       createGrid(method, len = 3, data = NULL)
Arguments:
  method: a string specifying which classification model to use. See
          'train' for a full list.
     len: an integer specifying the number of points on the grid for
          each tuning parameter.
    data: the training data (only needed in the case where the 'method'
          is 'cforest', 'earth', 'bagEarth', 'fda', 'bagFDA', 'rpart',
          'svmRadial', 'pam', 'lars2', 'rf' or 'pls'). The outcome
          should be in a column called '.outcome'.

正しく動作する次の例を示します。

 createGrid("rda", 4)
 createGrid("lm")
 createGrid("nnet")
 
 ## data needed for SVM with RBF:
 ## Not run:
 
 tmp <- iris
 names(tmp)[5] <- ".outcome"
 head(tmp)
 createGrid("svmRadial", data = tmp, len = 4)
 ## End(Not run)

これで、私は何を間違っていますか?

フォローアップの質問:

len の引数としてと の引数createGridtuneLength関係は何trainですか? lentuneLength一緒に使用できますか? 彼らの関係は何ですか?

その他の役立つスレッド:

役立つ場合は、in での使用方法createGridを説明するスレッドを次に示します: caret::train: specify model-generation-parameterstraincaret

4

1 に答える 1

1

例から引っ張ってきたコードは、私にとっては問題なく動作します (Rhelp に投稿したときに存在していた問題が修正されていることに注意してください)。

tmp <- iris
 names(tmp)[5] <- ".outcome"
 head(tmp)
 createGrid("svmRadial", data = tmp, len = 4)
#-------
     .sigma   .C
1 0.7500934 0.25
2 0.7500934 0.50
3 0.7500934 1.00
4 0.7500934 2.00

編集:

>  createGrid("rf", data = tmp, len = 4)
randomForest 4.6-7
Type rfNews() to see new features/changes/bug fixes.

Attaching package: ‘randomForest’

The following object(s) are masked from ‘package:Hmisc’:

    combine

note: only 3 unique complexity parameters in default grid. Truncating the grid to 3 .

  .mtry
1     2
2     3
3     4

もう一度言います。どのような問題が残っていますか?

于 2013-02-12T19:19:57.770 に答える