Ignore:
Timestamp:
02/06/12 20:01:02 (2 years ago)
Author:
lanumek
Branch:
default
Children:
9835:e48466fc6eb2, 9841:05a160804431
rebase_source:
8cf30121654f25c9cb6d8ac9bdaf163e305d62da
Message:

Changed names of data sets (table replaced with data or name of the data set).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/reference/rst/code/randomindices2.py

    r9696 r9823  
    77import Orange 
    88 
    9 data = Orange.data.Table("lenses") 
     9lenses = Orange.data.Table("lenses") 
    1010 
    1111indices2 = Orange.data.sample.SubsetIndices2(p0=6) 
    1212 
    13 ind = indices2(data) 
     13ind = indices2(lenses) 
    1414print ind 
    15 data0 = data.select(ind, 0) 
    16 data1 = data.select(ind, 1) 
    17 print len(data0), len(data1) 
     15lenses0 = lenses.select(ind, 0) 
     16lenses1 = lenses.select(ind, 1) 
     17print len(lenses0), len(lenses1) 
    1818 
    1919print "\nIndices without playing with random generator" 
    2020for i in range(5): 
    21     print indices2(data) 
     21    print indices2(lenses) 
    2222 
    2323print "\nIndices with random generator" 
    24 indices2.random_generator = Orange.misc.Random(42)     
     24indices2.random_generator = Orange.core.RandomGenerator(42)     
    2525for i in range(5): 
    26     print indices2(data) 
     26    print indices2(lenses) 
    2727 
    2828print "\nIndices with randseed" 
     
    3030indices2.randseed = 42 
    3131for i in range(5): 
    32     print indices2(data) 
     32    print indices2(lenses) 
    3333 
    3434 
    3535print "\nIndices with p0 set as probability (not 'a number of')" 
    3636indices2.p0 = 0.25 
    37 print indices2(data) 
     37print indices2(lenses) 
    3838 
    3939print "\n... with stratification" 
    4040indices2.stratified = indices2.Stratified 
    41 ind = indices2(data) 
     41ind = indices2(lenses) 
    4242print ind 
    43 data2 = data.select(ind) 
    44 od = Orange.core.getClassDistribution(data) 
    45 sd = Orange.core.getClassDistribution(data2) 
     43lenses2 = lenses.select(ind) 
     44od = Orange.core.getClassDistribution(lenses) 
     45sd = Orange.core.getClassDistribution(lenses2) 
    4646od.normalize() 
    4747sd.normalize() 
     
    5151print "\n... and without stratification" 
    5252indices2.stratified = indices2.NotStratified 
    53 print indices2(data) 
    54 ind = indices2(data) 
     53print indices2(lenses) 
     54ind = indices2(lenses) 
    5555print ind 
    56 data2 = data.select(ind) 
    57 od = Orange.core.getClassDistribution(data) 
    58 sd = Orange.core.getClassDistribution(data2) 
     56lenses2 = lenses.select(ind) 
     57od = Orange.core.getClassDistribution(lenses) 
     58sd = Orange.core.getClassDistribution(lenses2) 
    5959od.normalize() 
    6060sd.normalize() 
     
    6464print "\n... stratified 'if possible'" 
    6565indices2.stratified = indices2.StratifiedIfPossible 
    66 print indices2(data) 
     66print indices2(lenses) 
    6767 
    6868print "\n... stratified 'if possible', after removing the first example's class" 
    69 data[0].setclass("?") 
    70 print indices2(data) 
     69lenses[0].setclass("?") 
     70print indices2(lenses) 
Note: See TracChangeset for help on using the changeset viewer.