Dear all, I have a set of data in this form: > str <data> 'data.frame': 1574 obs. of 14 variables: $ serial: int 12751 14157 7226 15663 11088 10464 1003 10427 11934 3999 ... $ plate : int 43 46 22 50 38 37 3 37 41 11 ... $ well : int 79 333 314 303 336 96 235 59 30 159 ... $ sample: int 266 295 151 327 231 218 21 218 249 84 ... $ target: chr "HEV 2-AI5IQWR" "Dientamoeba fragilis-AIHSPMK" "Astro 2 Liu-AI20UKB" "C difficile GDH-AIS086J" ... $ ori.ct: num 0 33.5 0 0 0 ... $ ct.out: int 0 1 0 0 0 0 0 1 0 0 ... $ mr : num -0.002 0.109 0.002 0 0.001 0.006 0.015 0.119 0.003 0.004 ... $ fcn : num 44.54 36.74 6.78 43.09 44.87 ... $ mr.out: int 0 1 0 0 0 0 0 1 0 0 ... $ oper.a: int 0 1 0 0 0 0 0 1 0 0 ... $ oper.b: int 0 1 0 0 0 0 0 1 0 0 ... $ oper.c: int 0 1 0 0 0 0 0 1 0 0 ... $ cons : int 0 1 0 0 0 0 0 1 0 0 ... from which I have selected two numerical variables correspondig to x and y in a Cartesian plane and one outcome variable (z): > df = subset(t.data, select = c(mr, fcn, cons)) > df$cons = factor(c("negative", "positive")) > head(df) mr fcn cons 1 -0.002 44.54 negative 2 0.109 36.74 positive 3 0.002 6.78 negative 4 0.000 43.09 positive 5 0.001 44.87 negative 6 0.006 2.82 positive
I created an SVM the method with the KERNLAB package with: > mod = ksvm(cons ~ mr+fcn, # i prefer it to the more canonical "." but the > outcome is the same data = df, type = "C-bsvc", kernel = "rbfdot", kpar = "automatic", C = 10, prob.model = TRUE) > mod Support Vector Machine object of class "ksvm" SV type: C-bsvc (classification) parameter : cost C = 10 Gaussian Radial Basis kernel function. Hyperparameter : sigma = 42.0923201429106 Number of Support Vectors : 1439 Objective Function Value : -12873.45 Training error : 0.39263 Probability model included. First of all, I am not sure if the model worked because 1439 support vectors out of 1574 data points means that over 90% of the data is required to fix the hyperplane. this does not look like a model but a patch. Secondly, the prediction is rubbish -- but this is another story -- and when I try to create a confusion table of the processed data I get: > pred = predict(mod, df, type = "probabilities") > acc = table(pred, df$cons) Error in table(pred, df$cons) : all arguments must have the same length which again is weird since mod, df and df$cons are made from the same dataframe. Coming to the actual error, I tried to plot the model with: > plot(mod, data = df) > kernlab::plot(mod, data = df) but I get this error: Error in .local(x, ...) : Only plots of classification ksvm objects supported Would you know what I am missing? Thank you -- Best regards, Luigi ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.