Different number of support vectors & decision values in R (using svm from "e1071") and matlab (fitcsvm) for one class classification
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nainsi Gupta
el 12 de Mzo. de 2024
Comentada: Nainsi Gupta
el 14 de Abr. de 2024
I am trying to run svm both on R and matlab.
R code:
data= df[, 1:2]
head(data)
sum(is.na(data))
data_bislery= as.numeric(data$PH, data$TDS)
mdl= svm(data_bislery,gamma = 1,nu = 0.5)
mdl$decision.values
mdl$SV
summary(mdl)
matlab code:
data= d_new(:,1:2)
y= ones(552,1)
model= fitcsvm(D,y,"KernelScale",1, Nu=0.5, KernelFunction="rbf")
[~,s]= predict(model, D)
Both the codes are giving different results. Even the data used for both the code is same but they are giving very different results.
Number of support vectors for R is 279 while in matlab are 286. R have -ve and +ve distance values while matlab has only positive decision values.
Please help me the theory behind both the softwares so that i can get same results when using same data on both the softwares.
0 comentarios
Respuesta aceptada
Raj
el 22 de Mzo. de 2024
As per my understanding, even though same algorithm is being implemented, in this case SVM, there can be differences in implemenation details that might lead to slightly different results. Implementation details such as optimization algorithm, numerical precision, or how edge cases are handled can be different in both 'R' and 'MATLAB'.
In theory, if you use the exact same data, preprocessing steps, SVM algorithm (including the kernel function), and all hyperparameters (like C, gamma for the RBF kernel, and nu ), you might expect to get very similar, if not identical, outputs from SVM in both R and MATLAB.
Hope this helps!
Más respuestas (0)
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!