Skip to main content

Evidence Theory Tools — utilities for Dempster-Shafer theory of belief functions

Project description

evtools

Evidence Theory Tools — a growing Python library of utilities for working with belief functions in the Dempster-Shafer theory of evidence.

Modules

Module Description
evtools.dsvector DSVector — unified container for any belief function representation
evtools.conversions Low-level conversions between all standard representations via the Fast Möbius Transform

evtools.dsvector

DSVector is the central object of evtools. It represents any belief function as a vector on 2^Ω, in both sparse (dict) and dense (numpy array) forms. The sparse representation is the master; the dense array is computed on demand and cached.

Kind enum

Kind Symbol Name
Kind.M m Basic Belief Assignment (mass function)
Kind.BEL bel Belief function
Kind.PL pl Plausibility function
Kind.B b Commonality function
Kind.Q q Implicability function
Kind.V v Conjunctive weight function
Kind.W w Disjunctive weight function

Constructors

from evtools.dsvector import DSVector, Kind

# Human-friendly: name focal elements as strings
m = DSVector.from_focal(["a", "b", "c"], {"a": 0.3, "b,c": 0.5})

# From a dense numpy array
m = DSVector.from_dense(["a", "b", "c"], np.array([0, 0.3, 0, 0, 0.5, 0, 0, 0.2]))

# From a sparse dict of frozensets
m = DSVector.from_sparse(["a", "b", "c"], {
    frozenset({"a"}):          0.3,
    frozenset({"b", "c"}):    0.5,
    frozenset({"a","b","c"}): 0.2,
})

Conversions

pl  = m.to(Kind.PL)   # returns a new DSVector with kind=Kind.PL
bel = m.to_bel()      # shortcut
b   = m.to_b()        # commonality
q   = m.to_q()        # implicability
v   = m.to_v()        # conjunctive weights (requires subnormal BBA)
w   = m.to_w()        # disjunctive weights (requires subnormal BBA)

Accessing values

m.sparse                     # dict[frozenset, float]
m.dense                      # np.ndarray of length 2^n
m[frozenset({"a"})]          # value for a given subset (0.0 if absent)
for subset, value in m: ...  # iterate over non-zero focal elements

evtools.conversions

Low-level conversion functions between all standard representations, implemented using the Fast Möbius Transform (FMT) from Smets (2002) and Denoeux (2008). All functions operate on plain np.ndarray vectors of length 2^n.

Every conversion is available as a <source>to<target> function, e.g. mtob, pltom, qtow, beltov, etc.

import numpy as np
from evtools.conversions import mtob, mtopl, mtobel, mtow

m = np.array([0.0, 0.3, 0.5, 0.2])  # ∅, {a}, {b}, {a,b}

print(mtob(m))    # commonality function
print(mtopl(m))   # plausibility function
print(mtobel(m))  # belief function
print(mtow(m))    # disjunctive weight function

Installation

pip install evtools-dst

Or from source:

git clone https://github.com/daviddavkanmercier/evtools.git
cd evtools
pip install -e .

Running tests

pip install -e ".[dev]"
pytest tests/

References

  • P. Smets. The application of the matrix calculus to belief functions, International Journal of Approximate Reasoning, 31(1–2):1–30, 2002.
  • T. Denœux. Conjunctive and disjunctive combination of belief functions induced by non-distinct bodies of evidence, Artificial Intelligence, 172:234–264, 2008.
  • D. Mercier, B. Quost, T. Denœux, Refined modeling of sensor reliability in the belief function framework using contextual discounting, Information Fusion, Vol. 9, Issue 2, pp 246-258, April 2008.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

evtools_dst-0.2.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

evtools_dst-0.2.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file evtools_dst-0.2.0.tar.gz.

File metadata

  • Download URL: evtools_dst-0.2.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for evtools_dst-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e14a7af4a58941334d23b809872137ebbd24015fc09b8c307ae2c6639f567b00
MD5 00d4f31f80c6a188addd53f2ffb70621
BLAKE2b-256 3e93ebe46da1aaf1e60dfd5412c4aa0e09ce8fa8b4b9820e7b7e2e35b0df1cc5

See more details on using hashes here.

File details

Details for the file evtools_dst-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: evtools_dst-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for evtools_dst-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da3789b7cba0cd3a0c0c4815e982b42bebbe4df782df6a6cff9adcdb2c6aaac7
MD5 58484a8d50f7a6019450a64ebd38a164
BLAKE2b-256 0a64fd41c38fbd3a8276bf8efe846fdd19589c1a4c1dc6dfe9a152bb625e74b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page