[R] Kernlab Error in .local(x, ...) when plot model

Luigi Marongiu m@rongiu@luigi @ending from gm@il@com
Fri Dec 28 14:28:06 CET 2018

Dear all,
I have generated a model with KERNLAB using the following steps:
the data is a dataframe df of two numerical variables x and y, and
each point is assigned a z value that is a factor of two levels:
positive and negative. The data has the strucutre:
> str(df)
'data.frame': 1574 obs. of 3 variables:
$y : num ...
$x : num ...
$x : Factor w/ 2 levels "negative", "positive"...

I set the model with:
mod = ksvm(z ~., data = df, type = "C-bscv", kernel = "rbfdot", kpar =
"automatic", C = 10, prob.model  = TRUE)
which gives me:
> mod
Support Vector Machine object of class "ksvm"

SV type: S-bsvc (classification)
parameter: cost  C = 10
Gaussian Radial basis kernel function.
Hyperparameter: sigma = 45.69...

Number of support vectors: 1436

Objective function value : -12792.1
Training error: 0.388818
Probability model included

But when I try to plot the model I get:
>plot(mod, data = df) OR kernlab::plot(mod, data = df)
Error in .local(x, ...) :
Only plots of classification ksvm object supported

What did I get wrong?
Thank you

Best regards,

More information about the R-help mailing list