Home | Trees | Indices | Help |
|
---|
|
object --+ | dict --+ | FreqDist
A frequency distribution for the outcomes of an experiment. A frequency distribution records the number of times each outcome of an experiment has occurred. For example, a frequency distribution could be used to record the frequency of each word type in a document. Formally, a frequency distribution can be defined as a function mapping from each sample to the number of times that sample occurred as an outcome.
Frequency distributions are generally constructed by running a number of experiments, and incrementing the count for a sample every time it is an outcome of an experiment. For example, the following code will produce a frequency distribution that encodes how often each word occurs in a text:
>>> fdist = FreqDist() >>> for word in tokenize.whitespace(sent): ... fdist.inc(word.lower())
An equivalent way to do this is with the initializer:
>>> fdist = FreqDist(word.lower() for word in tokenize.whitespace(sent))
|
|||
new empty dictionary |
|
||
None |
|
||
int
|
|
||
int
|
|
||
list
|
|
||
int
|
|
||
|
|||
int
|
|
||
float |
|
||
any or None
|
|
||
|
|||
|
|||
|
|||
sequence of any |
|
||
string |
|
||
string |
|
||
|
|||
Inherited from Inherited from |
|
|||
Inherited from |
|
Construct a new frequency distribution. If In particular,
|
Increment this
|
|
|
|
|
Return the count of a given sample. The count of a sample is defined
as the number of times that sample outcome was recorded by this
|
Return the frequency of a given sample. The frequency of a sample is
defined as the count of that sample divided by the total number of sample
outcomes that have been recorded by this
|
Return the sample with the greatest number of outcomes in this
frequency distribution. If two or more samples have the same number of
outcomes, return one of them; which sample is returned is undefined. If
no outcomes have occurred in this frequency distribution, return
|
Plot the given samples from the frequency distribution. If no samples are specified, use all samples, in lexical sort order. (Requires Matplotlib to be installed.)
|
Plot the most frequent samples of the frequency distribution. (Requires Matplotlib to be installed.)
|
Return the samples sorted in decreasing order of frequency. Instances
with the same count will be arbitrarily ordered. Instances with a count
of zero will be omitted. This method is
|
repr(x)
|
str(x)
|
x[y]
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Wed Aug 27 15:08:56 2008 | http://epydoc.sourceforge.net |