2017-07-10 10 views
0

をチューニングするとき、私は言葉の袋から始まる予測のためのSVMを訓練し、チューニングするCパラメータをキャレットを使用していたが、それは私にエラーを与えてい成果のラベルのようにdoes't:キャレットは、SCV

弓。

model.svm.tune <- train(Training.match ~ ., data = data.frame(
    Training.match = factor(Training.Data.old$Training.match, labels = c('no match', 'match')), 
    Text.features.dtm.df) %>% 
     filter(Training.Data.old$Data.tipe == 'train'), 
    method = 'svmRadial', 
    tuneLength = 9, 
    preProc = c("center","scale"), 
    metric="ROC", 
    trControl = trainControl(
     method="repeatedcv", 
     repeats = 5, 
     summaryFunction = twoClassSummary, 
     classProbs = T)) 

Error: At least one of the class levels is not a valid R variable name; This will cause errors when class probabilities are generated because the variables names will be converted to no.match, match . Please use factor levels that can be used as valid R variable names (see ?make.names for help).

元e1071中:: SVM()関数は、問題を与えるものではありません、したがって、私はエラーがチューニングFASEで発生すると仮定します

bow.model.svm.tune <- svm(Training.match ~ ., data = data.frame(
      Training.match = factor(Training.Data.old$Training.match, labels = c('no match', 'match')), 
      Text.features.dtm.df) %>% 
       filter(Training.Data.old$Data.tipe == 'train')) 

データは、単に成果因子であります

'data.frame': 1796 obs. of 1697 variables: 
$ Training.match   : Factor w/ 2 levels "no match","match": 2 1 1 1 1 1 1 1 2 1 ... 
$ azienda     : num 0.12 0 0 0 0 ... 
$ bus      : num 0.487 0 0 0 0 ... 
$ locale     : num 0.275 0 0 0 0 ... 
$ martini     : num 0.852 0.741 0.947 0.947 0.501 ... 
$ osp      : num 0.339 0 0 0 0 ... 
$ ospedale    : num 0.0389 0.0676 0.0864 0.0864 0.0915 ... 

おかげ

:変数とTFIDFのリストは、言葉ベクトルを変換しました

答えて

0

内部的に(trainを内部的に使用するか、自分でpredict.trainを使用する)、各クラスの確率に対して新しい列を作成します。あなたのコードが"no match"という列を期待している場合、"no.match"(それはdata.frameに変換されます)が表示されず、エラーがスローされます。

+0

あなたは正しいです(あなたが関数Dを書いてから期待通りです)。ありがとうtopepo! – Bakaburg

関連する問題