Skip to content

Commit

Permalink
checking in unsaved file
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilliams97 committed May 14, 2012
1 parent 8ba2acf commit 7c4d2c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions quiz7/q3.py
@@ -1,7 +1,7 @@
from __future__ import division
import math

def L(x):
def log10(x):
return math.log(x, 10)

def norm(lst):
Expand Down Expand Up @@ -49,13 +49,13 @@ def norm(lst):
# N = total number of docs
N = len(docs)
# Inverse doc frequency
idf = dict((term, L(N) - L(doc_counts[term])) for term in terms)
idf = dict((term, log10(N) - log10(doc_counts[term])) for term in terms)

print 'N = %d' % N
print 'doc_counts = %s' % doc_counts
print 'idf = %s' % idf

def get_tf(count): return 1.0 + L(count) if count else 0.0
def get_tf(count): return 1.0 + log10(count) if count else 0.0

# Compute tf-idf
tfidf = dict(
Expand Down
2 changes: 1 addition & 1 deletion quiz7/q4.py
Expand Up @@ -13,6 +13,6 @@ def get_precision(n):
relevant_precisions = [precisions[i] for i in range(N) if results[i]]
average_precision = sum(relevant_precisions)/len(relevant_precisions)

print 'Average precsion = %.3f' % average_precision
print 'Average precision = %.3f' % average_precision


0 comments on commit 7c4d2c2

Please sign in to comment.