Changeset 10772:522e3d166e79 in orange


Ignore:
Timestamp:
04/06/12 14:50:23 (2 years ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Map the weight vectors in LinearClassifier from internal liblinear order to the class_var.values order.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/liblinear_interface.cpp

    r10771 r10772  
    359359        nr_feature++; 
    360360 
     361    int* labels = new int[linmodel->nr_class]; 
     362    get_labels(linmodel, labels); 
     363 
    361364    weights = mlnew TFloatListList(nr_classifier); 
    362     for (int i = 0; i < nr_classifier; i++){ 
     365    for (int i = 0; i < nr_classifier; i++) 
     366    { 
    363367        weights->at(i) = mlnew TFloatList(nr_feature); 
     368    } 
     369 
     370    for (int i = 0; i < nr_classifier; i++) 
     371    { 
    364372        for (int j = 0; j < nr_feature; j++) 
    365             weights->at(i)->at(j) = linmodel->w[j*nr_classifier+i]; 
    366     } 
     373        { 
     374            weights->at((nr_classifier > 1)? labels[i]: 0)->at(j) = \ 
     375                    linmodel->w[j*nr_classifier + i]; 
     376        } 
     377    } 
     378    delete[] labels; 
    367379} 
    368380 
Note: See TracChangeset for help on using the changeset viewer.