A Python package for simple and efficient implementation of Evidential Reasoning (ER) methods.
Project description
ERTool
ERTool is a Python package designed for simple and efficient implementation of Evidential Reasoning (ER) methods. It aims to provide an intuitive and flexible approach for integrating ER processes, particularly suitable for data analysis and decision support systems.
Features
- Easy-to-use implementation of Evidential Reasoning.
- Efficient in handling complex ER tasks.
- Flexible interface suitable for various application scenarios.
Installation
You can install ERTool directly from PyPI using pip:
pip install ertool
Using Instruction
er_algorithm
ertool.er.er_algorithm(W, DBF, numOfEvidence, numOfProposition)
er_algorithm() can implement the Evidential Reasoning (ER) algorithm.
Input Variables
- W: A one-dimensional array of floats. It represents the weights of each evidence. These weights are used in the algorithm to adjust the influence of each evidence.
- DBF: A two-dimensional array of floats. It stands for "Degrees of Belief" and is one of the main inputs to the algorithm, used to represent the initial belief degree of each proposition supported by each evidence.
- numOfEvidence: An integer. It indicates the number of evidence tob e combined. In the DBF array, this typically corresponds to the number of rows.
- numOfProposition: An integer. It indicates the number of propositions or evidential grades. In the DBF array, this typically corresponds to the number of columns.
Output Values
- B Array: Upon completion of the algorithm, the B array is updated with the final calculation results. It reflects the degree of belief of each propostion or evidential grades for the object being assessed after combining all availble evidence. The pre-Numofproposition values in the B represent the belief degree of each proposition after evidence fusion. The last value of the B represents the belief degree of the global uncertainty.
- False (Boolean): It returns True if the algorithm successfully executes and completes all computations. If any error is encountered during execution (e.g., division by zero), it returns False.
dempster_shafer
ertool.er.dempster_shafer(DBF, numOfEvidence, numOfProposition)
dempster_shafer() can implement the original Dempster-Shafer evidence theory.
Input Variables
- DBF: A two-dimensional array of floats. It stands for "Degrees of Belief" and is one of the main inputs to the algorithm, used to represent the initial belief degree of each proposition supported by each evidence. The pre-Numofproposition values in the B represent the belief degree of each proposition after evidence fusion. The last value of the B represents the belief degree of the global uncertainty.
- numOfEvidence: An integer. It indicates the number of evidence tob e combined. In the DBF array, this typically corresponds to the number of rows.
- numOfProposition: An integer. It indicates the number of propositions or evidential grades. In the DBF array, this typically corresponds to the number of columns.
Output Values
- B Array: Upon completion of the algorithm, the B array is updated with the final calculation results. It reflects the degree of belief of each propostion or evidential grades for the object being assessed after combining all availble evidence.
- False (Boolean): It returns True if the algorithm successfully executes and completes all computations. If any error is encountered during execution (e.g., division by zero), it returns False.
show_er_result
ertool.er.show_er_result(B, P = None)
er.show_er_result() can visualize the rusult of evidential reasoning algorithm.
Input Variables
- B: The ER rusult of belief degree.
- P: The name array of propositions.
Quick Start
Here is a basic usage example of ERTool.
Consider a medical scenario. There are three medical experts (weights 10, 8, and 5). For one patient, the three experts rated the different likelihood of the diagnosis of cold, common pneumonia, COVID-19, and other diseases. As shown in the table.
Experts & Diseases | Expert 1 | Expert 2 | Expert 3 |
---|---|---|---|
Cold | 90% | 0 | 0 |
Common Pneumonia | 0 | 90% | 0 |
COVID-19 | 0 | 0 | 90% |
Other Diseases | 10% | 10% | 10% |
In this case, the numOfEvidence is 3 (the number of experts) and the numOfProposition is 4 (cold, common pneumonia, COVID-19, and other diseases).
The W array is the weights array of every expert and the ERTool package can normalize them automatically.
We can write the code using the ERTool package:
import ertool
import numpy as np
W = np.array([10,8,5])
DBF = np.array([[0.9, 0, 0, 0.1],
[0, 0.9, 0, 0.1],
[0, 0, 0.9, 0.1]])
# List or numpy array are both OK.
# W = [10,8,5]
# DBF = [[0.9, 0, 0, 0.1],
# [0, 0.9, 0, 0.1],
# [0, 0, 0.9, 0.1]]
numOfEvidence = 3
numOfProposition = 4
B = ertool.er.er_algorithm(W, DBF, numOfEvidence, numOfProposition)
print("The result:", B)
P = ['Cold', 'Common Pneumonia', 'COVID-19', 'Other Disease']
ertool.er.show_er_result(B, P)
With the code, we can calculate the probability that the patient will be diagnosed with each disease using evidential reasoning.
B: [0.43591353 0.30223338 0.15741322 0.10443986 0.]
According to the result, we can know that combining the opinions of the three experts, the probability of the patient being diagnosed with cold, common pneumonia, COVID-19 and uncertain are 0.43591353, 0.30223338, 0.15741322 and 0.10443986. The global uncertainty is the last value of B, and it is zero in this example.
Contributing
Contributions to ERTool are welcome. Please contact us for how to contribute to the project.
Contact
This project is supported by the National Institute of Health Data Science, Peking University. For any questions or suggestions, please contact us at tyshipku@gmail.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ERTool-0.2.0.tar.gz
.
File metadata
- Download URL: ERTool-0.2.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2d3fcff2e70e8b713c894cd43e33fbc626efad8d8752f337cbd69f064f1139e |
|
MD5 | 22566aa1f72ce591a7367de4d32e7cbf |
|
BLAKE2b-256 | e8a039791aee3572c89db3da475bdb1bf7601449d87ae47d0e640a8b995efe62 |
File details
Details for the file ERTool-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: ERTool-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae5e7fd6c68189ba42c99a0d5b249020c4584c58e52fcede72e8bea95db39a86 |
|
MD5 | 7fbba695e8ae6cd69d273008654d2b41 |
|
BLAKE2b-256 | 946ef01fe27300583f640c6a6eacf7461b657f2462aaf3f5aeebcb9d1accf600 |