Changeset 7921:86fe5044df34 in orange


Ignore:
Timestamp:
05/19/11 14:13:25 (3 years ago)
Author:
anze <anze.staric@…>
Branch:
default
Convert:
72ce8775f512c811a175908b16552209add75e73
Message:

Clean-up of Naive Bayes examples to remove horizontal scrollbar in documentation.

Location:
orange/doc/Orange/rst/code
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/doc/Orange/rst/code/bayes-plot-iris.py

    r7810 r7921  
    33 
    44iris = Orange.data.Table("iris.tab") 
    5 bayes = Orange.classification.bayes.NaiveLearner(iris) 
     5nb = Orange.classification.bayes.NaiveLearner(iris) 
    66 
    7 sepal_length, probabilities = zip(*bayes.conditional_distributions[0].items()) 
    8 probability_setosa, probability_versicolor, probability_virginica = zip(*probabilities) 
     7sepal_length, probabilities = zip(*nb.conditional_distributions[0].items()) 
     8p_setosa, p_versicolor, p_virginica = zip(*probabilities) 
    99 
    1010pylab.xlabel("sepal length") 
    1111pylab.ylabel("probability") 
    12 pylab.plot(sepal_length, probability_setosa, label="setosa", linewidth=2) 
    13 pylab.plot(sepal_length, probability_versicolor, label="versicolor", linewidth=2) 
    14 pylab.plot(sepal_length, probability_virginica, label="virginica", linewidth=2) 
     12pylab.plot(sepal_length, p_setosa, label="setosa", linewidth=2) 
     13pylab.plot(sepal_length, p_versicolor, label="versicolor", linewidth=2) 
     14pylab.plot(sepal_length, p_virginica, label="virginica", linewidth=2) 
    1515 
    1616pylab.legend(loc="best") 
  • orange/doc/Orange/rst/code/bayes-thresholdAdjustment.py

    r7919 r7921  
    66 
    77import Orange 
    8 import orngStat 
     8from Orange.classification import bayes 
     9from Orange.evaluation import testing, scoring 
     10 
    911table = Orange.data.Table("adult_sample.tab") 
    1012 
    11 bayes = Orange.classification.bayes.NaiveLearner(name="Naive Bayes") 
    12 adjusted_bayes = Orange.classification.bayes.NaiveLearner(adjust_threshold=True, name="Adjusted Naive Bayes") 
     13nb = bayes.NaiveLearner(name="Naive Bayes") 
     14adjusted_nb = bayes.NaiveLearner(adjust_threshold=True, name="Adjusted Naive Bayes") 
    1315 
    14 results = Orange.evaluation.testing.cross_validation([bayes, adjusted_bayes], table) 
    15 print orngStat.CA(results) 
     16results = testing.cross_validation([nb, adjusted_nb], table) 
     17print scoring.CA(results) 
Note: See TracChangeset for help on using the changeset viewer.