Ignore:
Timestamp:
11/08/12 17:12:25 (18 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Fix the weight vector exposed to python if liblinear internally reorders the values of the binary class.

(references #1239)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/liblinear_interface.cpp

    r10951 r11016  
    402402    else 
    403403    { 
     404        /* If the order of the liblinear internaly stored classes 
     405         * is different from the order of orange's class values, 
     406         * we reverse the weight vector. 
     407         */ 
     408        float factor = (labels[0] == 0)? 1.0f : -1.0f; 
     409 
    404410        for (int j = 0; j < nr_feature; j++) 
    405411        { 
    406             /* If there are more than 2 class values 
    407              */ 
    408412            if (nr_orange_weights > 1) 
    409413            { 
     414               /* There are more than 2 orange class values. This means 
     415                * there were no instances for one or more classed in the training 
     416                * data set. 
     417                */ 
    410418                weights->at(labels[0])->at(j) = linmodel->w[j]; 
    411419                weights->at(labels[1])->at(j) = - linmodel->w[j]; 
     
    413421            else 
    414422            { 
    415                 weights->at(0)->at(j) = linmodel->w[j]; 
     423                weights->at(0)->at(j) = factor * linmodel->w[j]; 
    416424            } 
    417425        } 
Note: See TracChangeset for help on using the changeset viewer.