So I want to determine the alpha
, beta
and gamma
values of my SVM classifier, I trained my SVM classifier and determined the alpha and support vectors. My support vectors have 3 variables per row, below are just ten rows from my support vector:
0.0904235536887480 -0.269325475875919 -0.678528701392414
-0.321039098061280 -0.507618180664821 -1.42365662798284
-0.0737761304021185 -0.269641311369441 -0.647521877863172
0.00105779420640393 -0.311226557946309 -0.667506146498475
0.0913098589312967 -0.289462325547514 -0.391261050348894
0.00622693949845773 -0.166248587146820 -0.149546793127464
-0.292302915842567 -0.564676268888150 -1.60153093563523
0.112997393643248 -0.310512134534035 -0.725281274142312
-0.135361511770186 -0.456321702624641 -1.26973221898260
-0.173160731078767 -0.434439033384469 -1.22687774941370
and similarly below are just ten rows from my alpha:
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
So what I basically doing is to determine the coefficients like so:
c = (-1)*[0.0904*x1 + (-0.2693)*x2 + (-0.6785)*x3] + (-1)*[(-0.321)*x1 + (-0.5076)*x2 + (-1.4236)*x3].....
and so on until the size of my alpha
.
So I coded the following in Matlab
syms x1, syms x2, syms x3;
alpha = SVMStruct.Alpha;
svm_vec = SVMStruct.SupportVectors;
for i = 1:size(alpha,1)
c(i) = alpha(i)*(svm_vec(i,1)*x1 + svm_vec(i,2)*x2 + svm_vec(i,3)*x3);
end
sum_it = sum(c);
But this created a very strange output:
(107845064549358722206080751595348329973204613074833920445585562521882937008164658045489239834546021458299139*x1)/50534761550197893278639420198779799540396107395587434771118149413836407509953624874438129483687080755200 + (95720990302914087945142311872326568914380675701489099929103269189530321664249312169660240242394455632803627*x2)/134178504805697854567421908803656709124500009291732154392279224305703564767807900528680550698065697177600 + (90626366614084720573448362168042659133754200934323766866906741825007634289583081638045482944881264585156183*x3)/125521827076297992982426946945356276277758073208394596044390242092432367040852552107475353878835652198400
is this the expected output? Why am I getting it as fractions?
Looking by the output, did I implement my equation correctly?