Changeset 9296:ec6867e235d3 in orange


Ignore:
Timestamp:
12/05/11 15:31:17 (2 years ago)
Author:
jzbontar <jure.zbontar@…>
Branch:
default
Convert:
3514b54fce964ecd266f4d9bbd4a26b8f9016032
Message:

SimpleTreeLearner random_generator argument

Location:
source/orange
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • source/orange/tdidt_simple.cpp

    r9169 r9296  
    5252    int type, *attr_split_so_far; 
    5353    PDomain domain; 
     54    PRandomGenerator randomGenerator; 
    5455}; 
    5556 
     
    485486        if (!args->attr_split_so_far[i]) { 
    486487            /* select random subset of attributes */ 
    487             if ((double)rand() / RAND_MAX < args->skipProb) 
     488            if (args->randomGenerator->randdouble() < args->skipProb) 
    488489                continue; 
    489490 
     
    607608} 
    608609 
    609 TSimpleTreeLearner::TSimpleTreeLearner(const int &weight, float maxMajority, int minInstances, int maxDepth, float skipProb, unsigned int seed) : 
     610TSimpleTreeLearner::TSimpleTreeLearner(const int &weight, float maxMajority, int minInstances, int maxDepth, float skipProb, PRandomGenerator rgen) : 
    610611    maxMajority(maxMajority), 
    611612    minInstances(minInstances), 
    612613    maxDepth(maxDepth), 
    613     skipProb(skipProb), 
    614     seed(seed) 
    615 { 
     614    skipProb(skipProb) 
     615{ 
     616    randomGenerator = rgen ? rgen : PRandomGenerator(mlnew TRandomGenerator()); 
    616617} 
    617618 
     
    641642    args.skipProb = skipProb; 
    642643    args.domain = ogen->domain; 
     644    args.randomGenerator = randomGenerator; 
    643645    args.type = ogen->domain->classVar->varType == TValue::INTVAR ? Classification : Regression; 
    644646 
    645     srand(seed); 
    646647    tree = build_tree(examples, ogen->numberOfExamples(), 0, NULL, &args); 
    647648 
  • source/orange/tdidt_simple.hpp

    r9168 r9296  
    4242    int maxDepth; //P 
    4343    float skipProb; //P 
    44     int seed; //P 
     44    PRandomGenerator randomGenerator; //P 
    4545 
    46     TSimpleTreeLearner(const int & =0, float=1.0, int=2, int=INT_MAX, float=0.0, unsigned int=0); 
     46    TSimpleTreeLearner(const int & =0, float=1.0, int=2, int=INT_MAX, float=0.0, PRandomGenerator=NULL); 
    4747    PClassifier operator()(PExampleGenerator, const int & =0); 
    4848}; 
Note: See TracChangeset for help on using the changeset viewer.