//
//SVM support vector machine model command.
//

//syntax with option
svm  [segment variable] by [explaining variables]/
options
;
/** Options
type              select kernel function 
                  liner  :liner function         u'*v + coef  
                  mult   :polynomial function    (u'*v + coef)**degree
                  gauss  :gaussian functio       exp(-delta*|u-v|^2)(default)
                  laplase:laplase function       exp(-delta*|u-v|) 
                  sigmoid:sigmoid function tanh  1/exp(1+exp(-*u'*v+coef))

margin=.xx      //soft margin 0 < .xx is hard mergin svm         (default = 1000.0) 
nu=.xx          //nu conditon parametar                          (default=0.5)
delta=.xx       //see kernel function at gamma                   (default=0.1 k:dimension of data)
degree=nn       //see kernel funciton at nn                      (default=4)
test=.yy        //.yy is rate of data record for inspection of model.  0.0 < .yy <= 1.0 (defalut=0.0)
nu = .xx        //.xx is nu used by nusvm                        (default=0.5)
coef = zz       // zz is constant coeficent for kernel           (default=0.0)
**/


//Example 1
hand kbn x y/
 1 0.019369357   0.526381373
 1 0.386283708   0.347418479
-1 0.903627442   0.208211454
-1 0.736431183   0.056018726
-1 0.701974639   0.371235275
 1 0.304254514   0.112965579
 1 0.29491199    0.646280255
-1 0.541982287   0.3297108
 1 0.382667239   0.301098282
-1 0.802787022   0.29755779
;

attr name type/
kbn code
;

//View point and supervised label (1 or -1) plot scat x y by kbn;

//Execute svm model by kernel function liner. svm kbn by x y/ type=liner ;

No.2 is incorrect recognition,so correct column is 2.

//get output of svm for inspection get freq@ana; //Draw graph point with svm value which shows separated space. plot scat x y svm;


//Draw graph points by correct flag. plot scat x y by correct;

supervised 1 and predict 1 then correct column is 1
supervised -1 and predict -1 then correct column is -1
supervised 1 and predict -1 then correct column is 2
supervised -1 and predict 1 then correct column is 3