class documentation

A conditional probability distribution modeling the experiments that were used to generate a conditional frequency distribution. A ConditionalProbDist is constructed from a ConditionalFreqDist and a ProbDist factory:

  • The ConditionalFreqDist specifies the frequency distribution for each condition.
  • The ProbDist factory is a function that takes a condition's frequency distribution, and returns its probability distribution. A ProbDist class's name (such as MLEProbDist or HeldoutProbDist) can be used to specify that class's constructor.

The first argument to the ProbDist factory is the frequency distribution that it should model; and the remaining arguments are specified by the factory_args parameter to the ConditionalProbDist constructor. For example, the following code constructs a ConditionalProbDist, where the probability distribution for each condition is an ELEProbDist with 10 bins:

>>> from nltk.corpus import brown
>>> from nltk.probability import ConditionalFreqDist
>>> from nltk.probability import ConditionalProbDist, ELEProbDist
>>> cfdist = ConditionalFreqDist(brown.tagged_words()[:5000])
>>> cpdist = ConditionalProbDist(cfdist, ELEProbDist, 10)
>>> cpdist['passed'].max()
'VBD'
>>> cpdist['passed'].prob('VBD')
0.423...
Method __init__ Construct a new conditional probability distribution, based on the given conditional frequency distribution and ProbDist factory.
Method __missing__ Undocumented
Instance Variable _factory_args Undocumented
Instance Variable _factory_kw_args Undocumented
Instance Variable _probdist_factory Undocumented

Inherited from ConditionalProbDistI:

Method __repr__ Return a string representation of this ConditionalProbDist.
Method conditions Return a list of the conditions that are represented by this ConditionalProbDist. Use the indexing operator to access the probability distribution for a given condition.
def __init__(self, cfdist, probdist_factory, *factory_args, **factory_kw_args): (source)

Construct a new conditional probability distribution, based on the given conditional frequency distribution and ProbDist factory.

Parameters
cfdist:ConditionalFreqDistThe ConditionalFreqDist specifying the frequency distribution for each condition.
probdist_factory:class or functionThe function or class that maps a condition's frequency distribution to its probability distribution. The function is called with the frequency distribution as its first argument, factory_args as its remaining arguments, and factory_kw_args as keyword arguments.
*factory_args:(any)Extra arguments for probdist_factory. These arguments are usually used to specify extra properties for the probability distributions of individual conditions, such as the number of bins they contain.
**factory_kw_args:(any)Extra keyword arguments for probdist_factory.
def __missing__(self, key): (source)

Undocumented

_factory_args = (source)

Undocumented

_factory_kw_args = (source)

Undocumented

_probdist_factory = (source)

Undocumented