class ConditionalProbDist(ConditionalProbDistI): (source)
Constructor: ConditionalProbDist(cfdist, probdist_factory, *factory_args, **factory_kw_args)
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 |
Undocumented |
Instance Variable | _factory |
Undocumented |
Instance Variable | _probdist |
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. |
Construct a new conditional probability distribution, based on the given conditional frequency distribution and ProbDist factory.
Parameters | |
cfdist:ConditionalFreqDist | The ConditionalFreqDist specifying the frequency distribution for each condition. |
probdist | The 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 | 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 | Extra keyword arguments for probdist_factory. |