[R] Kernlab's ksvm class.weights level name error

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Fri Jun 7 12:25:22 CEST 2019


Dear all,
I would like to use KSVM with weighted classes. Thus I created a named
vector as follows:

> VECT = c(1.0, 0.5, 0.7)
> names(VECT) = c("negative", "positive", "uncertain")
> VECT
 negative  positive uncertain
      1.0       0.5       0.7


The data TRAIN contains the following levels:

> unique(TRAIN$z)
[1] negative  positive  uncertain
Levels: negative positive uncertain

Actually, I copied and pasted these values to create VECT.
Then I ran the model as follows:

> mod = ksvm(z ~ a+b, data = TRAIN,
+                type = "C-svc",
+                kernel = "rbfdot",
+                kpar = "automatic",
+                C = 1,
+                prob.model = TRUE,
+                class.weights = VECT
+              )
Error in .local(x, ...) :
  At least one level name is missing or misspelled.

>
Since there are only values for the variable z and I pasted them into
VECT, how can this be a misspelling error?
Would you have any tips?
Thank you,
Luigi



More information about the R-help mailing list