Changeset 7421:9e664c0171e4 in orange


Ignore:
Timestamp:
02/04/11 12:33:41 (3 years ago)
Author:
jzbontar <jure.zbontar@…>
Branch:
default
Convert:
6aa9b69dc7151ed9efa2addbf33c65252688072e
Message:

PEP 8

Location:
orange
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/evaluation/testing.py

    r7413 r7421  
    3131list of learning algorithms is prepared. 
    3232 
     33part of `testing-test.py`_ (uses `voting.tab`_) 
     34 
    3335.. literalinclude:: code/testing-test.py 
    34     :start-after: # Read the data 
     36    :start-after: import random 
     37    :end-before: def printResults(res) 
    3538 
    3639After testing is done, classification accuracies can be computed and 
     
    3942.. literalinclude:: code/testing-test.py 
    4043    :pyobject: printResults 
     44 
     45.. _voting.tab: code/voting.tab 
     46.. _testing-test.py: code/testing-test.py 
     47 
     48Common Arguments 
     49================ 
    4150 
    4251""" 
  • orange/doc/Orange/rst/code/testing-test.py

    r7413 r7421  
    99majority = Orange.classification.majority.MajorityLearner(name="default") 
    1010learners = [bayes, tree, majority] 
    11  
    1211 
    1312def printResults(res): 
     
    3029    printResults(res) 
    3130 
    32 if "NO_RANDOMNESS" not in vars(): 
    33     print "\nproportionsTest that will give different results each time it is run" 
    34     for i in range(3): 
    35         res = Orange.evaluation.testing.proportionTest(learners, table, 0.7, randseed=random.randint(0, 100)) 
    36         printResults(res) 
     31print "\nproportionsTest that will give different results each time it is run" 
     32for i in range(3): 
     33    res = Orange.evaluation.testing.proportionTest(learners, table, 0.7, 
     34        randseed=random.randint(0, 100)) 
     35    printResults(res) 
    3736 
    3837print "\nproportionsTest + storing classifiers" 
    39 res = Orange.evaluation.testing.proportionTest(learners, table, 0.7, 100, storeClassifiers = 1) 
    40 print "#iter %i, #classifiers %i" % (len(res.classifiers), len(res.classifiers[0])) 
    41 print 
    42  
     38res = Orange.evaluation.testing.proportionTest(learners, table, 0.7, 100, 
     39    storeClassifiers=1) 
     40print "#iter %i, #classifiers %i" % \ 
     41    (len(res.classifiers), len(res.classifiers[0])) 
    4342 
    4443print "\nGood old 10-fold cross validation" 
     
    4645printResults(res) 
    4746 
    48  
    4947print "\nLearning curve" 
    5048prop = Orange.core.frange(0.2, 1.0, 0.2) 
    51 res = Orange.evaluation.testing.learningCurveN(learners, table, folds = 5, proportions = prop) 
     49res = Orange.evaluation.testing.learningCurveN(learners, table, folds=5, 
     50    proportions=prop) 
    5251for i in range(len(prop)): 
    5352    print "%5.3f:" % prop[i], 
     
    5554 
    5655print "\nLearning curve with pre-separated data" 
    57 indices = Orange.core.MakeRandomIndices2(table, p0 = 0.7) 
     56indices = Orange.core.MakeRandomIndices2(table, p0=0.7) 
    5857train = table.select(indices, 0) 
    5958test = table.select(indices, 1) 
    60 res = Orange.evaluation.testing.learningCurveWithTestData(learners, train, test, times = 5, proportions = prop) 
     59res = Orange.evaluation.testing.learningCurveWithTestData(learners, train, 
     60    test, times=5, proportions=prop) 
    6161for i in range(len(prop)): 
    6262    print "%5.3f:" % prop[i], 
    6363    printResults(res[i]) 
    64  
    6564 
    6665print "\nLearning and testing on pre-separated data" 
Note: See TracChangeset for help on using the changeset viewer.