2016-05-01 6 views
1

Ich habe einen Datensatz mit 28 Attributen. Die Antwortvariable ist binär (0 & 1). Ich habe versucht, SVM mit "Probability = T" zu verwenden, während ich es ausführe. Aber ich konnte die Wahrscheinlichkeitswerte vom Ergebnis immer noch nicht erhalten.Probleme beim Abrufen von Wahrscheinlichkeitswerten mit SVM in R

Hier mein Trainingsdatensatz ist (letztes Attribut ist meine Antwort variabel):

str(train) 
'data.frame': 73630 obs. of 29 variables: 
$ EMOTION_INDICATOR: num -2 -0.625 0.9 0 1.625 ... 
$ CLUSTER   : Factor w/ 8 levels "","cluster0",..: 4 7 5 1 1 3 8 6 7 1 ... 
$ GENDER   : Factor w/ 3 levels "","Female","Male": 2 2 2 1 1 3 3 2 3 1 ... 
$ AGE    : num 36 37 70 NA NA ... 
$ REGION   : Factor w/ 6 levels "","'Northern Ireland'",..: 5 6 5 1 1 6 4 4 6 1 ... 
$ WORKING   : Factor w/ 14 levels "","A","B","C",..: 4 14 8 1 1 6 4 3 4 1 ... 
$ MUSIC   : Factor w/ 7 levels "","A","B","C",..: 5 7 6 1 1 4 5 2 5 1 ... 
$ LIST_OWN   : num 1 1 6 NA NA ... 
$ LIST_BACK  : num 1 3 2 NA NA 0.5 2 0.5 6 NA ... 
$ Q1    : num 10 51 35 NA NA 29 51 25 69 NA ... 
$ Q2    : num 53 51 36 NA NA 7 49 25 71 NA ... 
$ Q3    : num 12 70 37 NA NA 26 51 23 70 NA ... 
$ Q4    : num 11 31 36 NA NA 2 50 24 7 NA ... 
$ Q5    : num 12 6 37 NA NA 51 73 22 10 NA ... 
$ Q6    : num 12 6 9 NA NA 51 47 22 68 NA ... 
$ Q7    : num 76 5 36 NA NA 29 50 30 11 NA ... 
$ Q8    : num 76 24 13 NA NA 72 52 10 10 NA ... 
$ Q9    : num 51 7 70 NA NA 12 36 48 53 NA ... 
$ Q10    : num 53 70 69 NA NA 9 91 18 75 NA ... 
$ Q11    : num 76 89 65 NA NA 53 53 18 86 NA ... 
$ Q12    : num 76 91 63 NA NA 5 52 16 89 NA ... 
$ Q13    : num 52 50 6 NA NA 51 77 17 99 NA ... 
$ Q14    : num 75 73 62 NA NA 70 78 21 100 NA ... 
$ Q15    : num 11 72 31 NA NA 33 48 19 67 NA ... 
$ Q16    : num 12 47.7 24.3 NA NA ... 
$ Q17    : num 71 74 51 NA NA 51 52 27 98 NA ... 
$ Q18    : num 23.6 52 31 NA NA ... 
$ Q19    : num 22.5 52 32 NA NA ... 
$ AVERAGE_RATING : Factor w/ 2 levels "0","1": 1 1 2 1 2 1 1 1 1 1 ... 

Mein Test-Set zu ähnlich sieht. Es hat 24544 Obs. mit 29 Variablen.

Dies ist der Code, den ich für SVM verwendet:

fitSVM <- svm(AVERAGE_RATING ~., data=train, na.action = na.omit,probability=T) 
predSVM <- predict(fitSVM,test[!rowSums(is.na(test)),],type="probability") 
table(predSVM,test$AVERAGE_RATING[!rowSums(is.na(test))],useNA="no") 
predSVM 0 1 
     0 8091 1523 
     1 3259 9865 

ich die richtige Ausgabe zu erhalten, aber ohne Wahrscheinlichkeitswerte:

attr(predSVM,"probabilities") 
NULL 

Bin ich etwas falsch?

Antwort

0

Sie müssen rufen predict mit:

predSVM <- predict(fitSVM,test[!rowSums(is.na(test)),], probability=T) 

Siehe ? predict.svm

+0

Vielen Dank, es hat funktioniert :) – OLK

Verwandte Themen