Changeset 5052:48a3a3da03cf in orange


Ignore:
Timestamp:
08/02/08 15:16:35 (6 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
04eeaddba0f466ce26c9a1c616d3bbb676900ff0
Message:
  • added a test for measure that needs a generator
File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/doc/reference/cb-measureattribute.py

    r526 r5052  
    6666tree = treeLearner(tab) 
    6767orngTree.printTxt(tree) 
     68 
     69print "\n\nRandom test based on the number of examples" 
     70class MeasureAttribute_Generator(orange.MeasureAttribute): 
     71     def __init__(self): 
     72         self.needs = orange.MeasureAttribute.Generator 
     73          
     74     def __call__(self, attr, generator, priorDist, weigthID): 
     75         import random 
     76         r = random.Random() 
     77         r.seed(len(generator)) 
     78         return r.random() 
     79      
     80treeLearner = orange.TreeLearner() 
     81treeLearner.split = orange.TreeSplitConstructor_Attribute(measure = MeasureAttribute_Generator()) 
     82tree = treeLearner(tab) 
     83orngTree.printTxt(tree) 
     84  
Note: See TracChangeset for help on using the changeset viewer.