R - "ksvm object does not contain probability errors" for one svm class?

I am trying to detect outliers and output as probabilities using one svm class in the kernlab R package. The data import and model building process all seem fine, but when I tried to predict the model by specifying type = "probabilities", it gives me the error "ksvm object not an error model". I am using version 3.1.0 and here is my code.

mydata <- read.table("C:/Temp/MyTrainData.csv", header = TRUE, sep=",", dec=".")
mydata1 <- as.matrix(mydata)
model <- ksvm(mydata1,type="one-svc",kernel="rbfdot",kpar="automatic",prob.model = TRUE)
mytest <- read.table("C:/Temp/MyTestData.csv", header = TRUE, sep=",", dec=".")
mytest1 <- as.matrix(mytest)
pred <- predict(model,mytest1,type="probabilities")

He gives the following:

Error in .local(object, ...) : 
  ksvm object contains no probability model. Make sure you set the paramater prob.model in ksvm during training.

As shown above, I already set prob.model = TRUE for the ksvm function and did not receive any error at this stage until I try to predict new data. I also tried the e1071 package but got a similar error. Just wondering if a probability option is allowed for one svm class? If not, is there any workaround for this or is supported by other popular software (e.g. RapidMiner)?

+4
source share

Source: https://habr.com/ru/post/1538834/


All Articles