フィルターのクリア

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

2 ビュー (過去 30 日間)
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.

採用された回答

Raj
Raj 2024 年 3 月 22 日
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!
  1 件のコメント
Nainsi Gupta
Nainsi Gupta 2024 年 4 月 14 日
Can you see the above mentioned code for both in R and Matlab and suggest what is going wrong?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by