)
HAM = (
    "play sports today",
    "went play sports",
    "secret sports event",
    "sports is today",
    "sports costs money",
)

print "=== Naive Bayes CLassifier ==="
c = NaiveBayesClassifier(SPAM, HAM)
print "Size of vocabulary: %d" % c.different_words
result("SPAM", c.spam.p, 0.3750)
result("secret|SPAM", c.spam.p_word("secret"), 0.3333)
result("secret|HAM",  c.ham.p_word("secret"), 0.0667)
result("SPAM|sports", c.p_spam_given_word("sports"), 0.1667)
result("SPAM|secret is secret)", c.p_spam_given_phrase("secret is secret"), 0.9615)
result("SPAM|today is secret)", c.p_spam_given_phrase("today is secret"), 0)

print "\n=== Naive Bayes CLassifier with Laplace Smoothing ==="
c = NaiveBayesClassifier(SPAM, HAM, 1)
result("SPAM", c.spam.p, 0.4)
result("HAM", c.ham.p, 0.6)
result("today|SPAM", c.spam.p_word("today"), 0.0476)
result("today|HAM",  c.ham.p_word("today"), 0.1111)
result("SPAM|today is secret)", c.p_spam_given_phrase("today is secret"), 0.4858)


from linear_regression import linear_regression, gaussian
from scipy import matrix
print "\n=== Linear Regression ==="
print "\n=== Problem 8 ==="
from bayes import NaiveBayesClassifier, result
SPAM = (
    "Top Gun",
    "Shy People",
    "Top Hat",
)
HAM = (
    "Top Gear",
    "Gun Shy",
)
c = NaiveBayesClassifier(SPAM, HAM, 1)
result("OLD", c.spam.p)
result("Top|OLD", c.spam.p_word("Top"))
result("OLD|Top", c.p_spam_given_word("Top"))


print "\n=== Problem 10 ==="
from linear_regression import linear_regression, gaussian
x = [1.0, 3.0, 4.0, 5.0,  9.0]
y = [2.0, 5.2, 6.8, 8.4, 14.8]
(w0, w1), err = linear_regression(x, y)
print "(w0=%.1f, w1=%.1f) err=%.2f" % (w0, w1, err)


print "\n=== Problem 12 ==="
from logic import Proposition, implies
print Proposition(
    lambda a: not a,
             "not a"