-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added cummulative probability distribution graph
- Loading branch information
Nicolas Weber
committed
Feb 20, 2009
1 parent
9a52026
commit 5b4e941
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |