필터 지우기
필터 지우기

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!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by