Ignore:
Timestamp:
07/01/13 16:24:25 (10 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Changed TSVMClassifier constructor interface.

It no longer requires "examples" table unless using a custom kernel
and no longer keeps the training "x_space" array (the passed svm_model
needs to 'own' the *(model->SV) array).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/libsvm_interface.hpp

    r10389 r11606  
    9898    PKernelFunc kernelFunc; //P custom kernel function 
    9999 
    100     PExampleTable tempExamples; 
    101  
    102100    TSVMLearner(); 
    103101    ~TSVMLearner(); 
     
    109107    virtual svm_node* init_problem(svm_problem &problem, PExampleTable examples, int n_elements); 
    110108    virtual int getNumOfElements(PExampleGenerator examples); 
    111     virtual TSVMClassifier* createClassifier(PVariable var, PExampleTable ex, svm_model* model, svm_node* x_space); 
     109    virtual TSVMClassifier* createClassifier( 
     110            PVariable var, PExampleTable examples, PExampleTable supportVectors, svm_model* model); 
    112111}; 
    113112 
     
    119118    virtual svm_node* example_to_svm(const TExample &ex, svm_node* node, float last=0.0, int type=0); 
    120119    virtual int getNumOfElements(PExampleGenerator examples); 
    121     virtual TSVMClassifier* createClassifier(PVariable var, PExampleTable ex, svm_model* model, svm_node* x_space); 
     120    virtual TSVMClassifier* createClassifier( 
     121            PVariable classVar, PExampleTable examples, PExampleTable supportVectors, svm_model* model); 
    122122}; 
    123123 
     
    128128    TSVMClassifier(){ 
    129129        this->model = NULL; 
    130         this->x_space = NULL; 
    131130    }; 
    132131 
    133     TSVMClassifier(const PVariable & , PExampleTable, svm_model*, svm_node*, PKernelFunc); 
     132    TSVMClassifier(const PVariable & , PExampleTable examples, PExampleTable supportVectors, 
     133            svm_model* model, PKernelFunc kernelFunc); 
     134 
    134135    ~TSVMClassifier(); 
    135136 
     
    145146    PFloatList probB; //P probB - pairwise probability information 
    146147    PExampleTable supportVectors; //P support vectors 
    147     PExampleTable examples; //P examples used to train the classifier 
     148    PExampleTable examples; //P (training instances when svm_type == Custom) 
    148149    PKernelFunc kernelFunc; //P custom kernel function 
    149150 
     
    159160private: 
    160161    svm_model *model; 
    161     svm_node *x_space; 
    162162}; 
    163163 
     
    166166    __REGISTER_CLASS 
    167167    TSVMClassifierSparse(){}; 
    168     TSVMClassifierSparse(PVariable var , PExampleTable ex, svm_model* model, 
    169             svm_node* x_space, bool useNonMeta, PKernelFunc kernelFunc) 
    170     :TSVMClassifier(var, ex, model, x_space, kernelFunc){ 
    171         this->useNonMeta=useNonMeta; 
     168    TSVMClassifierSparse(PVariable var, PExampleTable examples,  PExampleTable supportVectors, 
     169            svm_model* model, bool useNonMeta, PKernelFunc kernelFunc 
     170            ) :TSVMClassifier(var, examples, supportVectors, model, kernelFunc){ 
     171        this->useNonMeta = useNonMeta; 
    172172    } 
     173 
    173174    bool useNonMeta; //P include non meta attributes 
     175 
    174176protected: 
    175177    virtual svm_node* example_to_svm(const TExample &ex, svm_node* node, float last=0.0, int type=0); 
Note: See TracChangeset for help on using the changeset viewer.