]> granicus.if.org Git - liblinear/commitdiff
modifications are made for one-class svm:
authorHung-Yi Chou <hungyi.chou@deltaww.com>
Mon, 27 Jul 2020 01:57:38 +0000 (01:57 +0000)
committerHung-Yi Chou <hungyi.chou@deltaww.com>
Mon, 27 Jul 2020 02:24:49 +0000 (02:24 +0000)
-In liblinear.cpp, fix bug that rho is wrongly calculated

-In matlab/linear_model_matlab.c, fix bug that matlab did not
read rho from matlab model struct

-In matlab/train.c, a default nu was not set, now 0.5

linear.cpp
matlab/linear_model_matlab.c
matlab/train.c

index 9ef2b9e1ae0b0f94f2b7a1cde53952fe87cd760a..3edcede77de5fd8004bc29e736915fa155c3eaaa 100644 (file)
@@ -2455,9 +2455,9 @@ static void solve_oneclass_svm(const problem *prob, double *w, double *rho, doub
        for(i=0; i<l; i++)
        {
                double G = sparse_operator::dot(w, prob->x[i]);
-               if (alpha[i] == 0)
+               if (alpha[i] == 1)
                        lb = max(lb, G);
-               else if (alpha[i] == 1)
+               else if (alpha[i] == 0)
                        ub = min(ub, G);
                else
                {
index a048b6dda054660938d2c58822dd777dd9689c3e..a7350b7776c1d64a43264ec6898931b592114921 100644 (file)
@@ -171,11 +171,18 @@ const char *matlab_matrix_to_model(struct model *model_, const mxArray *matlab_s
        }
        id++;
 
+       // w
        ptr = mxGetPr(rhs[id]);
        model_->w=Malloc(double, w_size*nr_w);
        for(i = 0; i < w_size*nr_w; i++)
                model_->w[i]=ptr[i];
        id++;
+
+       // rho
+       ptr = mxGetPr(rhs[id]);
+       model_->rho = ptr[0];
+       id++;
+
        mxFree(rhs);
 
        return NULL;
index 498772a5dab2ef31aadc9eb075fe14d44b575a19..370765690655f01b3396cd6d7a43cc9386dc8653 100644 (file)
@@ -162,8 +162,9 @@ int parse_command_line(int nrhs, const mxArray *prhs[], char *model_file_name)
        // default values
        param.solver_type = L2R_L2LOSS_SVC_DUAL;
        param.C = 1;
-       param.eps = INF; // see setting below
        param.p = 0.1;
+       param.nu = 0.5;
+       param.eps = INF; // see setting below
        param.nr_weight = 0;
        param.weight_label = NULL;
        param.weight = NULL;