My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Natural Language Toolkit: Evaluation
#
# Copyright (C) 2001-2011 NLTK Project
# Author: Edward Loper <edloper@gradient.cis.upenn.edu>
# Steven Bird <sb@csse.unimelb.edu.au>
# URL: <http://www.nltk.org/>
# For license information, see LICENSE.TXT


"""
Utility functions for evaluating processing modules.
"""

import sys
import math
import random

try:
from scipy.stats.stats import betai
except ImportError:
betai = None

import nltk

from util import LazyConcatenation, LazyMap, LazyZip
from probability import FreqDist

def demo():
print '-'*75
reference = 'DET NN VB DET JJ NN NN IN DET NN'.split()
test = 'DET VB VB DET NN NN NN IN DET NN'.split()
print 'Reference =', reference
print 'Test =', test
print 'Confusion matrix:'
print ConfusionMatrix(reference, test)
print 'Accuracy:', accuracy(reference, test)

print '-'*75
reference_set = set(reference)
test_set = set(test)
print 'Reference =', reference_set
print 'Test = ', test_set
print 'Precision:', precision(reference_set, test_set)
print ' Recall:', recall(reference_set, test_set)
print 'F-Measure:', f_measure(reference_set, test_set)
print '-'*75

if __name__ == '__main__':
demo()

__all__ = ['ConfusionMatrix', 'accuracy',
'f_measure', 'log_likelihood', 'precision', 'recall',
'approxrand', 'edit_dist', 'windowdiff']

Change log

r8777 by StevenBird1 on Apr 10, 2011   Diff
Removed deprecated code, since 2.0 is not
backwards compatible.  Resolves  issue 558 .
Go to: 
Sign in to write a code review

Older revisions

r8730 by StevenBird1 on Mar 7, 2011   Diff
Updated NLTK copyright year range from
2001-2010 to 2001-2011
r8479 by StevenBird1 on Jan 12, 2010   Diff
Updated copyright period to 2001-2010
r8144 by edloper on Jun 1, 2009   Diff
Modified nltk-internal imports to
import values from the modules where
they are defined -- e.g., changed
"from nltk import FreqDist" to "from
nltk.probability import FreqDist".
...
All revisions of this file

File info

Size: 1410 bytes, 53 lines

File properties

svn:eol-style
native
svn:keywords
Author Date Id Revision
Powered by Google Project Hosting