evidencelib 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evidencelib-1.0.0/.github/workflows/ci.yml +40 -0
- evidencelib-1.0.0/.gitignore +8 -0
- evidencelib-1.0.0/.readthedocs.yaml +16 -0
- evidencelib-1.0.0/LICENSE +22 -0
- evidencelib-1.0.0/PKG-INFO +225 -0
- evidencelib-1.0.0/README.md +172 -0
- evidencelib-1.0.0/docs/api-reference.rst +31 -0
- evidencelib-1.0.0/docs/api.md +92 -0
- evidencelib-1.0.0/docs/conf.py +45 -0
- evidencelib-1.0.0/docs/contributing.md +21 -0
- evidencelib-1.0.0/docs/decision.md +47 -0
- evidencelib-1.0.0/docs/examples.md +12 -0
- evidencelib-1.0.0/docs/fusion-rules.md +84 -0
- evidencelib-1.0.0/docs/index.rst +36 -0
- evidencelib-1.0.0/docs/mass-functions.md +57 -0
- evidencelib-1.0.0/docs/models.md +59 -0
- evidencelib-1.0.0/docs/propositions.md +49 -0
- evidencelib-1.0.0/docs/quickstart.md +49 -0
- evidencelib-1.0.0/docs/references.md +11 -0
- evidencelib-1.0.0/docs/release-checklist.md +22 -0
- evidencelib-1.0.0/docs/requirements.txt +4 -0
- evidencelib-1.0.0/docs/theory.md +53 -0
- evidencelib-1.0.0/examples/basic_dst.py +16 -0
- evidencelib-1.0.0/examples/dsmt_fusion.py +13 -0
- evidencelib-1.0.0/examples/hybrid_dsmt.py +26 -0
- evidencelib-1.0.0/examples/rules_dst.py +24 -0
- evidencelib-1.0.0/examples/zadeh.py +23 -0
- evidencelib-1.0.0/pyproject.toml +47 -0
- evidencelib-1.0.0/src/evidencelib/__init__.py +8 -0
- evidencelib-1.0.0/src/evidencelib/exceptions.py +14 -0
- evidencelib-1.0.0/src/evidencelib/frame.py +198 -0
- evidencelib-1.0.0/src/evidencelib/mass.py +305 -0
- evidencelib-1.0.0/src/evidencelib/parser.py +104 -0
- evidencelib-1.0.0/src/evidencelib/proposition.py +80 -0
- evidencelib-1.0.0/src/evidencelib/py.typed +1 -0
- evidencelib-1.0.0/tests/test_dsmt.py +59 -0
- evidencelib-1.0.0/tests/test_dst.py +124 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
tests:
|
|
9
|
+
name: Python ${{ matrix.python-version }}
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
- name: Install
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install --upgrade pip
|
|
24
|
+
python -m pip install -e ".[dev]"
|
|
25
|
+
- name: Test
|
|
26
|
+
run: python -m pytest -q
|
|
27
|
+
|
|
28
|
+
build:
|
|
29
|
+
name: Build package
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.12"
|
|
36
|
+
- name: Build
|
|
37
|
+
run: |
|
|
38
|
+
python -m pip install --upgrade pip build
|
|
39
|
+
python -m build
|
|
40
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 evidencelib contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: evidencelib
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Computational belief functions for DST and DSmT.
|
|
5
|
+
Project-URL: Documentation, https://evidencelib.readthedocs.io/en/latest/
|
|
6
|
+
Project-URL: Source, https://github.com/itaprac/evidencelib
|
|
7
|
+
Project-URL: Issues, https://github.com/itaprac/evidencelib/issues
|
|
8
|
+
Author: evidencelib contributors
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 evidencelib contributors
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: belief-functions,dempster-shafer,dsmt,dst,evidence-theory
|
|
33
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
34
|
+
Classifier: Intended Audience :: Science/Research
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Programming Language :: Python :: 3
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
41
|
+
Requires-Python: >=3.10
|
|
42
|
+
Provides-Extra: dev
|
|
43
|
+
Requires-Dist: build>=1.0; extra == 'dev'
|
|
44
|
+
Requires-Dist: myst-parser>=4.0; extra == 'dev'
|
|
45
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
46
|
+
Requires-Dist: sphinx-rtd-theme>=3.0; extra == 'dev'
|
|
47
|
+
Requires-Dist: sphinx>=8.0; extra == 'dev'
|
|
48
|
+
Provides-Extra: docs
|
|
49
|
+
Requires-Dist: myst-parser>=4.0; extra == 'docs'
|
|
50
|
+
Requires-Dist: sphinx-rtd-theme>=3.0; extra == 'docs'
|
|
51
|
+
Requires-Dist: sphinx>=8.0; extra == 'docs'
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
|
|
54
|
+
# evidencelib
|
|
55
|
+
|
|
56
|
+
[](https://github.com/itaprac/evidencelib/actions/workflows/ci.yml)
|
|
57
|
+
[](https://evidencelib.readthedocs.io/en/latest/?badge=latest)
|
|
58
|
+
[](LICENSE)
|
|
59
|
+
|
|
60
|
+
Python library for belief-function calculations in Dempster-Shafer theory
|
|
61
|
+
(DST) and Dezert-Smarandache theory (DSmT).
|
|
62
|
+
|
|
63
|
+
`evidencelib` provides a compact quantitative core for finite frames: symbolic
|
|
64
|
+
propositions, basic belief assignments, evidence fusion rules, belief measures,
|
|
65
|
+
and pignistic decision support.
|
|
66
|
+
|
|
67
|
+
Documentation is available on
|
|
68
|
+
[Read the Docs](https://evidencelib.readthedocs.io/en/latest/).
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
You can install `evidencelib` using pip:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install evidencelib
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
For local development:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/itaprac/evidencelib.git
|
|
84
|
+
cd evidencelib
|
|
85
|
+
python3.10 -m venv .venv
|
|
86
|
+
source .venv/bin/activate
|
|
87
|
+
pip install -e ".[dev,docs]"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Run the test suite:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
python -m pytest -q
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Build the documentation locally:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
python -m sphinx -W -b html docs docs/_build/html
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Available Functionality
|
|
105
|
+
|
|
106
|
+
The library contains:
|
|
107
|
+
|
|
108
|
+
### Models
|
|
109
|
+
|
|
110
|
+
| Constructor | Description |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| `Frame.dst(...)` | Shafer's classical DST model with exhaustive and mutually exclusive hypotheses. |
|
|
113
|
+
| `Frame.dsmt(...)` | Free DSm model where hypotheses may overlap. |
|
|
114
|
+
| `Frame.hybrid(...)` | Constrained DSm model with explicit emptiness or exclusivity constraints. |
|
|
115
|
+
|
|
116
|
+
### Proposition Algebra
|
|
117
|
+
|
|
118
|
+
| Operation | Meaning |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| `A \| B` | Union / disjunction, `A ∪ B`. |
|
|
121
|
+
| `A & B` | Intersection / conjunction, `A ∩ B`. |
|
|
122
|
+
| `frame.proposition("A ∩ (B ∪ C)")` | Parse a proposition from text. |
|
|
123
|
+
| `frame.elements()` | Generate the model's power set or hyper-power set. |
|
|
124
|
+
|
|
125
|
+
### Belief Measures
|
|
126
|
+
|
|
127
|
+
| Method | Description |
|
|
128
|
+
| --- | --- |
|
|
129
|
+
| `mass(A)` | Direct mass assigned to a proposition. |
|
|
130
|
+
| `belief(A)` | Sum of masses contained in `A`. |
|
|
131
|
+
| `plausibility(A)` | Sum of masses intersecting `A`. |
|
|
132
|
+
| `commonality(A)` | Sum of masses containing `A`. |
|
|
133
|
+
| `conflict` | Mass assigned to the empty proposition. |
|
|
134
|
+
|
|
135
|
+
### Fusion Rules
|
|
136
|
+
|
|
137
|
+
| Method | Description |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| `conjunctive(...)` | Unnormalized conjunctive rule. |
|
|
140
|
+
| `dsmc(...)` | Classic DSm rule on a free DSm frame. |
|
|
141
|
+
| `smets(...)` | TBM/Smets rule, keeping conflict on the empty proposition. |
|
|
142
|
+
| `dempster(...)` | Normalized Dempster rule. |
|
|
143
|
+
| `yager(...)` | Yager rule, moving conflict to total ignorance. |
|
|
144
|
+
| `dsmh(...)` | Hybrid DSm rule for constrained models. |
|
|
145
|
+
| `dubois_prade(...)` | Static Dubois-Prade-style conflict transfer. |
|
|
146
|
+
| `pcr5(...)` | PCR5 for two sources. |
|
|
147
|
+
| `pcr6(...)` | PCR6 for two or more sources. |
|
|
148
|
+
|
|
149
|
+
### Decision Support
|
|
150
|
+
|
|
151
|
+
| Method | Description |
|
|
152
|
+
| --- | --- |
|
|
153
|
+
| `pignistic()` | Singleton pignistic scores. |
|
|
154
|
+
| `pignistic_regions()` | Probability distribution over disjoint model regions. |
|
|
155
|
+
| `decision()` | Singleton with the largest pignistic score. |
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Usage Example
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from evidencelib import Frame
|
|
163
|
+
|
|
164
|
+
frame = Frame.dst(["A", "B"])
|
|
165
|
+
A, B = frame.symbols()
|
|
166
|
+
|
|
167
|
+
m1 = frame.mass({
|
|
168
|
+
A: 0.6,
|
|
169
|
+
A | B: 0.4,
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
m2 = frame.mass({
|
|
173
|
+
B: 0.3,
|
|
174
|
+
A | B: 0.7,
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
print(m1.dempster(m2).to_dict())
|
|
178
|
+
print(m1.pcr5(m2).to_dict())
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Output:
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
{"A": 0.5121951219512195, "A|B": 0.34146341463414637, "B": 0.14634146341463414}
|
|
185
|
+
{"A": 0.54, "A|B": 0.28, "B": 0.18}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Free DSmT example:
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
frame = Frame.dsmt(["A", "B"])
|
|
192
|
+
A, B = frame.symbols()
|
|
193
|
+
|
|
194
|
+
m = frame.mass({
|
|
195
|
+
A: 0.2,
|
|
196
|
+
B: 0.3,
|
|
197
|
+
A & B: 0.4,
|
|
198
|
+
A | B: 0.1,
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
print(m.pignistic())
|
|
202
|
+
print(m.pignistic_regions())
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
In DSmT, singleton hypotheses can overlap, so `pignistic()` returns decision
|
|
206
|
+
scores that do not necessarily sum to one. Use `pignistic_regions()` for a
|
|
207
|
+
probability distribution over disjoint Venn regions.
|
|
208
|
+
|
|
209
|
+
More examples are available in the [`examples/`](examples/) directory and in
|
|
210
|
+
the documentation.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## References
|
|
215
|
+
|
|
216
|
+
- Shafer, G. (1976). *A Mathematical Theory of Evidence*. Princeton University Press.
|
|
217
|
+
- Smarandache, F., & Dezert, J. (eds.). *Advances and Applications of DSmT for Information Fusion*.
|
|
218
|
+
- Dezert, J., & Smarandache, F. *An Introduction to DSmT*.
|
|
219
|
+
- Zadeh, L. A. (1986). A simple view of the Dempster-Shafer theory of evidence and its implication for the rule of combination. *AI Magazine*, 7(2), 85-90.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
`evidencelib` is released under the MIT License.
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# evidencelib
|
|
2
|
+
|
|
3
|
+
[](https://github.com/itaprac/evidencelib/actions/workflows/ci.yml)
|
|
4
|
+
[](https://evidencelib.readthedocs.io/en/latest/?badge=latest)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
Python library for belief-function calculations in Dempster-Shafer theory
|
|
8
|
+
(DST) and Dezert-Smarandache theory (DSmT).
|
|
9
|
+
|
|
10
|
+
`evidencelib` provides a compact quantitative core for finite frames: symbolic
|
|
11
|
+
propositions, basic belief assignments, evidence fusion rules, belief measures,
|
|
12
|
+
and pignistic decision support.
|
|
13
|
+
|
|
14
|
+
Documentation is available on
|
|
15
|
+
[Read the Docs](https://evidencelib.readthedocs.io/en/latest/).
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
You can install `evidencelib` using pip:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install evidencelib
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
For local development:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
git clone https://github.com/itaprac/evidencelib.git
|
|
31
|
+
cd evidencelib
|
|
32
|
+
python3.10 -m venv .venv
|
|
33
|
+
source .venv/bin/activate
|
|
34
|
+
pip install -e ".[dev,docs]"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Run the test suite:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
python -m pytest -q
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Build the documentation locally:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
python -m sphinx -W -b html docs docs/_build/html
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Available Functionality
|
|
52
|
+
|
|
53
|
+
The library contains:
|
|
54
|
+
|
|
55
|
+
### Models
|
|
56
|
+
|
|
57
|
+
| Constructor | Description |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `Frame.dst(...)` | Shafer's classical DST model with exhaustive and mutually exclusive hypotheses. |
|
|
60
|
+
| `Frame.dsmt(...)` | Free DSm model where hypotheses may overlap. |
|
|
61
|
+
| `Frame.hybrid(...)` | Constrained DSm model with explicit emptiness or exclusivity constraints. |
|
|
62
|
+
|
|
63
|
+
### Proposition Algebra
|
|
64
|
+
|
|
65
|
+
| Operation | Meaning |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `A \| B` | Union / disjunction, `A ∪ B`. |
|
|
68
|
+
| `A & B` | Intersection / conjunction, `A ∩ B`. |
|
|
69
|
+
| `frame.proposition("A ∩ (B ∪ C)")` | Parse a proposition from text. |
|
|
70
|
+
| `frame.elements()` | Generate the model's power set or hyper-power set. |
|
|
71
|
+
|
|
72
|
+
### Belief Measures
|
|
73
|
+
|
|
74
|
+
| Method | Description |
|
|
75
|
+
| --- | --- |
|
|
76
|
+
| `mass(A)` | Direct mass assigned to a proposition. |
|
|
77
|
+
| `belief(A)` | Sum of masses contained in `A`. |
|
|
78
|
+
| `plausibility(A)` | Sum of masses intersecting `A`. |
|
|
79
|
+
| `commonality(A)` | Sum of masses containing `A`. |
|
|
80
|
+
| `conflict` | Mass assigned to the empty proposition. |
|
|
81
|
+
|
|
82
|
+
### Fusion Rules
|
|
83
|
+
|
|
84
|
+
| Method | Description |
|
|
85
|
+
| --- | --- |
|
|
86
|
+
| `conjunctive(...)` | Unnormalized conjunctive rule. |
|
|
87
|
+
| `dsmc(...)` | Classic DSm rule on a free DSm frame. |
|
|
88
|
+
| `smets(...)` | TBM/Smets rule, keeping conflict on the empty proposition. |
|
|
89
|
+
| `dempster(...)` | Normalized Dempster rule. |
|
|
90
|
+
| `yager(...)` | Yager rule, moving conflict to total ignorance. |
|
|
91
|
+
| `dsmh(...)` | Hybrid DSm rule for constrained models. |
|
|
92
|
+
| `dubois_prade(...)` | Static Dubois-Prade-style conflict transfer. |
|
|
93
|
+
| `pcr5(...)` | PCR5 for two sources. |
|
|
94
|
+
| `pcr6(...)` | PCR6 for two or more sources. |
|
|
95
|
+
|
|
96
|
+
### Decision Support
|
|
97
|
+
|
|
98
|
+
| Method | Description |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `pignistic()` | Singleton pignistic scores. |
|
|
101
|
+
| `pignistic_regions()` | Probability distribution over disjoint model regions. |
|
|
102
|
+
| `decision()` | Singleton with the largest pignistic score. |
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Usage Example
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from evidencelib import Frame
|
|
110
|
+
|
|
111
|
+
frame = Frame.dst(["A", "B"])
|
|
112
|
+
A, B = frame.symbols()
|
|
113
|
+
|
|
114
|
+
m1 = frame.mass({
|
|
115
|
+
A: 0.6,
|
|
116
|
+
A | B: 0.4,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
m2 = frame.mass({
|
|
120
|
+
B: 0.3,
|
|
121
|
+
A | B: 0.7,
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
print(m1.dempster(m2).to_dict())
|
|
125
|
+
print(m1.pcr5(m2).to_dict())
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Output:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
{"A": 0.5121951219512195, "A|B": 0.34146341463414637, "B": 0.14634146341463414}
|
|
132
|
+
{"A": 0.54, "A|B": 0.28, "B": 0.18}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Free DSmT example:
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
frame = Frame.dsmt(["A", "B"])
|
|
139
|
+
A, B = frame.symbols()
|
|
140
|
+
|
|
141
|
+
m = frame.mass({
|
|
142
|
+
A: 0.2,
|
|
143
|
+
B: 0.3,
|
|
144
|
+
A & B: 0.4,
|
|
145
|
+
A | B: 0.1,
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
print(m.pignistic())
|
|
149
|
+
print(m.pignistic_regions())
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
In DSmT, singleton hypotheses can overlap, so `pignistic()` returns decision
|
|
153
|
+
scores that do not necessarily sum to one. Use `pignistic_regions()` for a
|
|
154
|
+
probability distribution over disjoint Venn regions.
|
|
155
|
+
|
|
156
|
+
More examples are available in the [`examples/`](examples/) directory and in
|
|
157
|
+
the documentation.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## References
|
|
162
|
+
|
|
163
|
+
- Shafer, G. (1976). *A Mathematical Theory of Evidence*. Princeton University Press.
|
|
164
|
+
- Smarandache, F., & Dezert, J. (eds.). *Advances and Applications of DSmT for Information Fusion*.
|
|
165
|
+
- Dezert, J., & Smarandache, F. *An Introduction to DSmT*.
|
|
166
|
+
- Zadeh, L. A. (1986). A simple view of the Dempster-Shafer theory of evidence and its implication for the rule of combination. *AI Magazine*, 7(2), 85-90.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
`evidencelib` is released under the MIT License.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
API Reference
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
Frame
|
|
5
|
+
-----
|
|
6
|
+
|
|
7
|
+
.. autoclass:: evidencelib.Frame
|
|
8
|
+
:members:
|
|
9
|
+
:undoc-members:
|
|
10
|
+
|
|
11
|
+
MassFunction
|
|
12
|
+
------------
|
|
13
|
+
|
|
14
|
+
.. autoclass:: evidencelib.MassFunction
|
|
15
|
+
:members:
|
|
16
|
+
:undoc-members:
|
|
17
|
+
|
|
18
|
+
Proposition
|
|
19
|
+
-----------
|
|
20
|
+
|
|
21
|
+
.. autoclass:: evidencelib.Proposition
|
|
22
|
+
:members:
|
|
23
|
+
:undoc-members:
|
|
24
|
+
|
|
25
|
+
Exceptions
|
|
26
|
+
----------
|
|
27
|
+
|
|
28
|
+
.. automodule:: evidencelib.exceptions
|
|
29
|
+
:members:
|
|
30
|
+
:undoc-members:
|
|
31
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# API
|
|
2
|
+
|
|
3
|
+
## Frame
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
Frame.dst(atoms)
|
|
7
|
+
Frame.dsmt(atoms)
|
|
8
|
+
Frame.hybrid(atoms, empty=(), exclusive=False)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Useful methods:
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
frame.symbols()
|
|
15
|
+
frame.symbols("A B")
|
|
16
|
+
frame.atom("A")
|
|
17
|
+
frame.proposition("A & (B | C)")
|
|
18
|
+
frame.mass({ ... })
|
|
19
|
+
frame.elements()
|
|
20
|
+
frame.region_count
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Proposition
|
|
24
|
+
|
|
25
|
+
Propositions are immutable and hashable.
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
A | B
|
|
29
|
+
A & B
|
|
30
|
+
str(A | B)
|
|
31
|
+
(A & B).is_empty
|
|
32
|
+
(A | B).cardinality
|
|
33
|
+
(A & B).union_atoms()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`|` means union/disjunction. `&` means intersection/conjunction.
|
|
37
|
+
|
|
38
|
+
## MassFunction
|
|
39
|
+
|
|
40
|
+
Create:
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
m = frame.mass({A: 0.4, B: 0.2, A | B: 0.4})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Inspect:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
m.items()
|
|
50
|
+
m.focal()
|
|
51
|
+
m.to_dict()
|
|
52
|
+
m.total_mass
|
|
53
|
+
m.conflict
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Measures:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
m.mass(A)
|
|
60
|
+
m.belief(A)
|
|
61
|
+
m.plausibility(A)
|
|
62
|
+
m.commonality(A)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Fusion:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
m1.conjunctive(m2)
|
|
69
|
+
m1.dsmc(m2)
|
|
70
|
+
m1.smets(m2)
|
|
71
|
+
m1.dempster(m2)
|
|
72
|
+
m1.yager(m2)
|
|
73
|
+
m1.dubois_prade(m2)
|
|
74
|
+
m1.dsmh(m2)
|
|
75
|
+
m1.pcr5(m2)
|
|
76
|
+
m1.pcr6(m2, m3)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Decision support:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
m.pignistic()
|
|
83
|
+
m.pignistic_regions()
|
|
84
|
+
m.decision()
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Errors
|
|
88
|
+
|
|
89
|
+
- `InvalidMassError`: mass values are negative or do not sum to one.
|
|
90
|
+
- `TotalConflictError`: Dempster normalization is undefined because conflict is one.
|
|
91
|
+
- `ValueError`: propositions belong to different frames or expression parsing fails.
|
|
92
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
7
|
+
sys.path.insert(0, str(ROOT / "src"))
|
|
8
|
+
|
|
9
|
+
project = "evidencelib"
|
|
10
|
+
author = "evidencelib contributors"
|
|
11
|
+
copyright = "2026, evidencelib contributors"
|
|
12
|
+
release = "1.0.0"
|
|
13
|
+
version = "1.0"
|
|
14
|
+
|
|
15
|
+
extensions = [
|
|
16
|
+
"myst_parser",
|
|
17
|
+
"sphinx.ext.autodoc",
|
|
18
|
+
"sphinx.ext.autosummary",
|
|
19
|
+
"sphinx.ext.intersphinx",
|
|
20
|
+
"sphinx.ext.napoleon",
|
|
21
|
+
"sphinx.ext.viewcode",
|
|
22
|
+
"sphinx_rtd_theme",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
templates_path = ["_templates"]
|
|
26
|
+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
|
27
|
+
|
|
28
|
+
html_theme = "sphinx_rtd_theme"
|
|
29
|
+
html_title = "evidencelib documentation"
|
|
30
|
+
html_theme_options = {
|
|
31
|
+
"collapse_navigation": False,
|
|
32
|
+
"navigation_depth": 4,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
autodoc_typehints = "description"
|
|
36
|
+
autosummary_generate = True
|
|
37
|
+
napoleon_google_docstring = True
|
|
38
|
+
napoleon_numpy_docstring = True
|
|
39
|
+
|
|
40
|
+
intersphinx_mapping = {
|
|
41
|
+
"python": ("https://docs.python.org/3", None),
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
myst_heading_anchors = 3
|
|
45
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Development setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
python3.10 -m venv .venv
|
|
7
|
+
source .venv/bin/activate
|
|
8
|
+
pip install -e ".[dev,docs]"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Checks
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
python -m pytest -q
|
|
15
|
+
python -m sphinx -W -b html docs docs/_build/html
|
|
16
|
+
python -m build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Release
|
|
20
|
+
|
|
21
|
+
Follow `docs/release-checklist.md`.
|