-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated docs and renamed some stuff and moved some stuff.
- Loading branch information
Showing
10 changed files
with
222 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
############# | ||
Distributions | ||
############# | ||
|
||
At the core of each probabilistic models are known distributions. This package implements the following distributions | ||
|
||
- :class:`probabilistic_model.distributions.distributions.SymbolicDistribution` | ||
- :class:`probabilistic_model.distributions.distributions.IntegerDistribution` | ||
- :class:`probabilistic_model.distributions.multinomial.MultinomialDistribution` | ||
- :class:`probabilistic_model.distributions.distributions.DiracDeltaDistribution` | ||
- :class:`probabilistic_model.distributions.uniform.UniformDistribution` | ||
- :class:`probabilistic_model.distributions.gaussian.GaussianDistribution` | ||
- :class:`probabilistic_model.distributions.gaussian.TruncatedGaussianDistribution` | ||
|
||
There is plenty of literature for each of those distributions, hence I will present only the interface to univariate | ||
distributions in general. | ||
|
||
Univariate Distributions | ||
======================== | ||
|
||
.. autoapi-inheritance-diagram:: probabilistic_model.distributions.distributions.UnivariateDistribution | ||
:parts: 1 | ||
|
||
The :class:`probabilistic_model.distributions.distributions.UnivariateDistribution` class extends probabilistic models | ||
by the following properties/methods | ||
|
||
- :attr:`probabilistic_model.distributions.distributions.UnivariateDistribution.representation` | ||
- :meth:`probabilistic_model.distributions.distributions.UnivariateDistribution.pdf` | ||
- :meth:`probabilistic_model.distributions.distributions.UnivariateDistribution.plot` | ||
|
||
Continuous Distributions | ||
************************ | ||
|
||
.. autoapi-inheritance-diagram:: probabilistic_model.distributions.distributions.ContinuousDistribution | ||
:parts: 1 | ||
|
||
The :class:`probabilistic_model.distributions.distributions.ContinuousDistribution` class extends univariate | ||
distributions by the straight forward method | ||
:meth:`probabilistic_model.distributions.distributions.ContinuousDistribution.cdf`. Also a default implementation of | ||
:meth:`probabilistic_model.distributions.distributions.ContinuousDistribution.plot` is provided that uses samples to | ||
plot the pdf, cdf, expectation and mode. | ||
|
||
A bit more interesting are the following methods: | ||
|
||
- :meth:`probabilistic_model.distributions.distributions.ContinuousDistribution.conditional` | ||
- :meth:`probabilistic_model.distributions.distributions.ContinuousDistribution.conditional_from_singleton` | ||
- :meth:`probabilistic_model.distributions.distributions.ContinuousDistribution.conditional_from_simple_interval` | ||
- :meth:`probabilistic_model.distributions.distributions.ContinuousDistribution.conditional_from_complex_interval` | ||
|
||
These methods handle the creation of conditional distributions on the real line. The first one is a general handling | ||
mechanism and will result in either of the latter three methods. The second creates a | ||
:class:`probabilistic_model.distributions.distributions.DiracDeltaDistribution` and the last two have to be implemented | ||
by the respective subclasses. | ||
|
||
Note that for many distributions such as the Gaussian distribution it is, mathematically speaking, quite complicated to | ||
provide a fully functional conditional implementation. | ||
See `this example`_ to get an idea of what I am talking about. | ||
|
||
.. _this example: examples/truncated_gaussians.ipynb | ||
|
||
|
||
Discrete Distributions | ||
********************** | ||
|
||
.. autoapi-inheritance-diagram:: | ||
probabilistic_model.distributions.distributions.IntegerDistribution | ||
probabilistic_model.distributions.distributions.SymbolicDistribution | ||
:parts: 1 | ||
|
||
The final part are discrete distributions such as the Symbolic and Integer distributions. This can be thought of as | ||
tabular distributions over discrete variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
###################### | ||
Probabilistic Circuits | ||
###################### | ||
|
||
Probabilistic Circuits (PCs) define a framework for tractable, probabilistic inference. | ||
You can read about PCs in detail here :cite:p:`choi2020probabilistic`. | ||
|
||
This package provides the following datastructures for PCs: | ||
|
||
- :class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.DecomposableProductUnit` | ||
- :class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.SmoothSumUnit` | ||
- :class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.DeterministicSumUnit` | ||
|
||
|
||
Datastructures in the Module | ||
============================ | ||
This section will run through the datastructures implemented for PCs that are necessary to fully understand | ||
manipulation and functionality of circuits. | ||
|
||
|
||
Probabilistic Circuit | ||
************************************************************************************************ | ||
|
||
.. autoapi-inheritance-diagram:: probabilistic_model.probabilistic_circuit.probabilistic_circuit.ProbabilisticCircuit | ||
:parts: 1 | ||
|
||
The most important aspect of the | ||
:class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.ProbabilisticCircuit` class, is the inheritance | ||
from `networkx.DiGraph <https://networkx.org/documentation/stable/reference/classes/digraph.html>`_ . | ||
A PC in this sense is a directed acyclic graph (DAG) where the nodes are computational units | ||
or distributions. The edges represent how the nodes are combined to form the general model. | ||
|
||
The nodes that can be added to a PC have to inherit from | ||
:class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.ProbabilisticCircuitMixin` such that they | ||
correctly work with inference algorithms. | ||
|
||
Additionally, PCs inherit from probabilistic models. Since undirected cycles inside a circuit are possible, it is also | ||
possible that some sub-circuit has to be evaluated multiple times. Inference methods from this class cache the results | ||
at every node, such that results are not calculated multiple times. The caches are cleared after each inference run. | ||
See the :class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.graph_inference_caching_wrapper` and | ||
:class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.cache_inference_result` decorators for more | ||
information. | ||
|
||
|
||
Probabilistic Circuit Mixin | ||
*************************************************************************************************** | ||
|
||
.. autoapi-inheritance-diagram:: probabilistic_model.probabilistic_circuit.probabilistic_circuit.ProbabilisticCircuitMixin | ||
:parts: 1 | ||
|
||
|
||
This class serves as a `mixin class <https://en.wikipedia.org/wiki/Mixin>`_ for components that can be used in a | ||
:class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.ProbabilisticCircuit` | ||
|
||
Nodes inside a PC have to inherit from | ||
:class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.ProbabilisticCircuitMixin` such that they work | ||
as intended with PCs. Besides being an abstract specialization of a Probabilistic Model, it is important that the | ||
hash method of such a component refers to the objects id. NetworkX uses the hashes of objects as so to speak pointers | ||
in their graphs. Since PCs can certainly contain components that could be seen as equal but yet have to exist multiple | ||
times, there is, up to my knowledge, no better way of defining the hash. | ||
|
||
|
||
Decomposable Product Unit | ||
************************* | ||
|
||
.. autoapi-inheritance-diagram:: probabilistic_model.probabilistic_circuit.probabilistic_circuit.DecomposableProductUnit | ||
:parts: 1 | ||
|
||
:class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.DecomposableProductUnit` represent, as the name | ||
suggests, a decomposable product unit. | ||
Edges that have instances of this class as a source must not be weighted. Besides that, there is nothing special about | ||
them. | ||
|
||
Smooth and Deterministic Sum Units | ||
*************** | ||
|
||
.. autoapi-inheritance-diagram:: probabilistic_model.probabilistic_circuit.probabilistic_circuit.DeterministicSumUnit | ||
:parts: 1 | ||
|
||
:class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.SmoothSumUnit` and | ||
:class:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.DeterministicSumUnit` represent smooth and | ||
deterministic summation operations just as described in the theory behind it. Edges that have these as source, must | ||
be weighted. | ||
|
||
A notable addition to circuits as described by :cite:p:`choi2020probabilistic` is the | ||
:meth:`probabilistic_model.probabilistic_circuit.probabilistic_circuit.SmoothSumUnit.mount_with_interaction_terms` | ||
method. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "3.0.2" | ||
__version__ = "3.0.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.