Skip to content

Commit

Permalink
added cummulative probability distribution graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Weber committed Feb 20, 2009
1 parent 9a52026 commit 5b4e941
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drawnumpredict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import numpredict

from pylab import *

def cumulativegraph(data, vec1, high, k=5, weightfun=numpredict.gaussianweight):
t1 = arange(0.0, high, 1)
cprob = array([numpredict.probguess(data, vec1, 0, v, k, weightfun)
for v in t1])
plot(t1, cprob)
show() # this does user interaction

if __name__ == '__main__':
s = numpredict.wineset3(k=500)

# Draw graph that shows p(price | [rating=99, age=20])
print 'Real price 1:', numpredict.wineprice(99.0, 20.0)
print 'Real price 2:', 0.6 * numpredict.wineprice(99.0, 20.0)
cumulativegraph(s, [99.0, 20.0], 120)

0 comments on commit 5b4e941

Please sign in to comment.