Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # define named vector
- > VECT = c(1.0, 0.5, 0.7)
- > names(VECT) = c("negative", "positive", "uncertain")
- > VECT
- negative positive uncertain
- 1.0 0.5 0.7
- # show levels of dataframe
- > unique(TRAIN$z)
- [1] negative positive uncertain
- Levels: negative positive uncertain
- # run model with named vector
- > 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.
- # second approach
- > mod = ksvm(cons ~ mr+fcn, data = TRAIN,
- + type = "C-svc",
- + kernel = "rbfdot",
- + kpar = "automatic",
- + C = 1,
- + prob.model = TRUE,
- + class.weights = c("negative" = 0.5,
- + "positive" = 1,
- + "uncertain" = 0.7)
- + )
- Error in .local(x, ...) :
- At least one level name is missing or misspelled.
- # third approach
- > VECT = c(1, 10, 5)
- > names(VECT) = c("negative", "positive", "uncertain")
- > VECT
- negative positive uncertain
- 1 10 5
- > mod = ksvm(cons ~ mr+fcn, data = TRAIN,
- + type = "C-svc",
- + kernel = "rbfdot",
- + kpar = "automatic",
- + C = c(0.5, 1, 0.7),
- + prob.model = TRUE,
- + class.weights = VECT
- + )
- Error in .local(x, ...) :
- At least one level name is missing or misspelled.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement