我尝试使用以下命令
调整R中的多项式SVMsvmPFitReduced <- train(
x=dataTrain[,predModelContinuous],
y=dataTrain[,outcome],
method = "svmPoly",
maxit = 1000,
metric = "ROC",
tuneGrid = svmPGrid,
trControl = trCtrl
)
但我发现了错误
Error in train.default(x = dataTrain[, predModelContinuous], y = dataTrain[, :
final tuning parameters could not be determined
数据集结构是
str(dataTrain)
'data.frame': 40001 obs. of 42 variables:
$ PolNum : num 2e+08 2e+08 2e+08 2e+08 2e+08 ...
$ sex : Factor w/ 2 levels "Male","Female": 1 1 1 2 1 2 1 1 1 2 ...
$ type : Factor w/ 6 levels "A","B","C","D",..: 3 1 1 2 2 4 3 3 3 2 ...
$ catgry : Ord.factor w/ 3 levels "Large"<"Medium"<..: 2 2 2 3 3 3 3 2 2 2 ...
$ occup : Factor w/ 5 levels "Employed","Housewife",..: 2 1 1 1 5 4 1 1 4 2 ...
$ age : num 48 23 23 39 24 39 28 43 45 38 ...
$ group : Factor w/ 20 levels "1","2","3","4",..: 15 16 12 16 14 8 16 9 12 8 ...
$ bonus : Ord.factor w/ 21 levels "-50"<"-40"<"-30"<..: 14 8 4 3 5 2 5 5 1 15 ...
$ poldur : num 7 1 1 14 2 4 11 2 8 5 ...
$ value : num 1120 21755 18430 11930 24850 ...
$ adind : Factor w/ 2 levels "No","Yes": 2 1 1 2 1 2 2 2 1 1 ...
$ Pcode : chr "SC22" "CT109" "MA1" "SA12" ...
$ Area : Factor w/ 10 levels "CT","JU","MA",..: 7 1 3 6 6 6 6 4 1 2 ...
$ Density : num 270.5 57.3 43.2 167.9 169.8 ...
$ Prem : num 1159 532 527 197 908 ...
$ Premad : num 53.1 413.7 410.7 61.6 824.6 ...
$ numclm : num 0 1 0 1 0 0 0 1 0 0 ...
$ Invite : num 1 1 1 1 1 1 1 1 1 1 ...
$ Renewaltp : num 1302 928 632 291 960 ...
$ Renewalad : num 58.4 599 440.4 71.3 682 ...
$ Markettp : num 1110 884 565 253 833 ...
$ Marketad : num 53.4 611.4 431.6 55.5 587 ...
$ Premtot : num 1212 532 527 259 908 ...
$ Renewaltot : num 1361 928 632 362 960 ...
$ Markettot : num 1163 884 565 309 833 ...
$ Renew : Ord.factor w/ 2 levels "No"<"Yes": 1 1 1 1 1 1 1 1 1 1 ...
$ Premchng : num 1.12 1.74 1.2 1.4 1.06 ...
$ Compmeas : num 1.17 1.05 1.12 1.17 1.15 ...
$ numclmRec : Ord.factor w/ 3 levels "None"<"One"<"Two or more": 1 2 1 2 1 1 1 2 1 1 ...
$ PremChngRec: Factor w/ 20 levels "[0.546,0.758)",..: 16 20 18 19 14 3 7 19 17 11 ...
$ ageRec : Factor w/ 20 levels "[19,22)","[22,25)",..: 14 2 2 9 2 9 4 11 12 9 ...
$ valueRec : Factor w/ 20 levels "[ 1005, 3290)",..: 1 15 13 9 17 5 12 12 19 1 ...
$ densityRec : Factor w/ 20 levels "[ 14.4, 25.0)",..: 19 6 5 15 15 13 15 1 5 11 ...
$ CompmeasRec: Factor w/ 20 levels "[0.716,0.869)",..: 12 6 10 13 12 18 11 16 18 14 ...
$ poldurRec : Ord.factor w/ 16 levels "1"<"2"<"3"<"4"<..: 7 1 1 14 2 4 11 2 8 5 ...
$ ageST : num 0.407 -1.34 -1.34 -0.222 -1.27 ...
$ numclmST : num -0.433 1.627 -0.433 1.627 -0.433 ...
$ PremchngST : num 0.591 3.709 0.98 1.985 0.265 ...
$ valueST : num -1.462 0.499 0.183 -0.434 0.793 ...
$ DensityST : num 1.918 -0.748 -0.924 0.636 0.659 ...
$ CompmeasST : num 0.224 -0.539 -0.098 0.248 0.113 ...
$ poldurST : num 0.097 -1.2 -1.2 1.61 -0.984 ...
the trCtrl <- trainControl(method = "cv",summaryFunction = twoClassSummary,returnData =FALSE,classProbs = TRUE)
and predictors and outcome have been grouped as follows.
predCtg<-c("sex","type","catgry","occup","bonus","Area","adind","group") predCont<-c("age","numclm","Premchng","value","Density","Compmeas","poldur") predContStd<-c("ageST","numclmST","PremchngST","valueST","DensityST","CompmeasST","poldurST") predFactorized<-c("ageRec","numclmRec","PremChngRec","CompmeasRec","poldurRec","densityRec","valueRec"); outcome="Renew"; predModelContinuous<-c(predCtg,predContStd)
如果需要,我可以将Dropbox链接发布到数据
提前感谢您提供任何帮助
答案 0 :(得分:0)
您是否检查了svmPGrid
参数的tuneGrid
值?在您提供的代码中无处可见,我猜这是特定错误的潜在原因。看看这个问题的答案:Error in train.default(x, y, weights = w, ...) : final tuning parameters could not be determined
希望这有帮助!