Different number of support vectors & decision values in R (using svm from "e1071") and matlab (fitcsvm) for one class classification

3 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Raj
Raj am 22 Mär. 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!

Weitere Antworten (0)

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by