Skip to main content

ERTool: A Python Package for Efficient Implementation of the Evidential Reasoning Approach for Multi-Source Evidence Fusion

Project description

ERTool

ERTool is a Python Package for Efficient Implementation of Multi-Source Evidence Fusion Based on the Evidential Reasoning Approach. It aims to provide an intuitive and flexible approach for integrating ER processes, particularly suitable for data analysis and decision support systems. For more information, please visit https://ertool.online/.

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, numOfPropositions)

er_algorithm() can implement the Evidential Reasoning (ER) algorithm.

Input

  • W: A one-dimensional array of floats. It represents the weights of each piece of 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 to be combined. In the DBF array, this typically corresponds to the number of rows.
  • numOfPropositions: An integer. It indicates the number of propositions or evidential grades. In the DBF array, this typically corresponds to the number of columns.

Output

  • 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 proposition or evidential grades for the object being assessed after combining all available 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_rule

ertool.er.dempster_rule(DBF, numOfEvidence, numOfPropositions)

dempster_rule() can implement the original Dempster-Shafer evidence theory.

Input

  • 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 to be combined. In the DBF array, this typically corresponds to the number of rows.
  • numOfPropositions: An integer. It indicates the number of propositions or evidential grades. In the DBF array, this typically corresponds to the number of columns.

Output

  • B Array: Upon completion of the Dempster's Rule, the B array is updated with the final calculation results. It reflects the degree of belief of each proposition or evidential grades for the object being assessed after combining all available 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.

yager_rule

ertool.er.yager_rule(DBF, numOfEvidence, numOfPropositions)

yager_rule() can implement the original Yager's Rule.

Input

  • 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 to be combined. In the DBF array, this typically corresponds to the number of rows.
  • numOfPropositions: An integer. It indicates the number of propositions or evidential grades. In the DBF array, this typically corresponds to the number of columns.

Output

  • B Array: Upon completion of the Yager's Rule, the B array is updated with the final calculation results. It reflects the degree of belief of each proposition or evidential grades for the object being assessed after combining all available 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.

murphy_rule

ertool.er.murphy_rule(DBF, numOfEvidence, numOfPropositions)

murphy_rule() can implement the original Murphy's Rule.

Input

  • 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 to be combined. In the DBF array, this typically corresponds to the number of rows.
  • numOfPropositions: An integer. It indicates the number of propositions or evidential grades. In the DBF array, this typically corresponds to the number of columns.

Output

  • B Array: Upon completion of the Murphy's Rule, the B array is updated with the final calculation results. It reflects the degree of belief of each proposition or evidential grades for the object being assessed after combining all available 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 result of evidential reasoning algorithm.

Input

  • B: The ER result of belief degree.
  • P: The name array of propositions.

run_algorithm_from_file

ertool.er.run_algorithm_from_file(file_path, algorithm = ER)

run_algorithm_from_file() reads CSV or XLSX files and performs multi-source evidence fusion on the data using ER approach or Dempster-Shafer’s theory.

Input

  • file_path: A string. The location of the CSV or XLSX file. Note that the format of data strictly follows the format of the provided template.
  • algorithm: 'ER', 'DS', 'yager' or 'murphy'. 'ER' stands for using the Evidence Inference algorithm, 'DS' stands for using the Dempster-Shafer algorithm, 'yager' stands for using the Yager's Rule, and 'murphy' stands for using the Murphy's Rule.

Output

  • B Array: Upon completion of the algorithm, the B array is updated with the final calculation results. It reflects the degree of belief in each proposition or evaluation grade for the object being assessed after combining all available evidence. The first numofPropositions members in the B represent the belief degree in each proposition after evidence fusion. The last member of the B represents the belief degree in 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.

multi_level_multi_source

ertool.er.multi_level_multi_source(folder_path)

The multi_level_multi_source() function can perform multi-level multi-source evidence fusion for folders that have already been structured using directory tree recursion method.

Input

  • folder_path: A string. The folder address of the data that requires multi-level multi-source evidence fusion is stored in a fixed format.

Output

The result of multi-level multi-source evidence fusion is generated in the root folder and written into the “Objects_combined.csv” file.

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%

In this case, the numOfEvidence is 3 (the number of experts) and the numOfPropositions is 3 (cold, common pneumonia and COVID-19).

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:

from ertool import er
import numpy as np

W = np.array([10,8,5])
DBF = np.array([[0.9, 0, 0], 
                [0, 0.9, 0], 
                [0, 0, 0.9]])

# List or numpy array are both OK.
# W = [10,8,5]
# DBF = [[0.9, 0, 0], 
#        [0, 0.9, 0], 
#        [0, 0, 0.9]]

numOfEvidence = 3
numOfPropositions = 3
B = er.er_algorithm(W, DBF, numOfEvidence, numOfPropositions)
print("The result: ", B)

P = ['Cold', 'Common Pneumonia', 'COVID-19']
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.

The result: [0.43317251 0.307059 0.16390311 0.09586537]

The calculation results show that the probability of the patient being diagnosed with a cold, common pneumonia, and COVID-19 are 0.43317251, 0.307059, and 0.16390311, respectively. The last member of B represents global uncertainty, and it is 0.09586537 in this example.

Contributing

Contributions to ERTool are welcome. Please contact us for how to contribute to the project.

Reference

Tongyue Shi, Liya Guo, Zeyuan Shen, Guilan Kong. ERTool: A Python Package for Efficient Implementation of the Evidential Reasoning Approach for Multi-Source Evidence Fusion. 2024.

Contact

This project is supported by Peking University. For any questions or suggestions, please contact us at tyshipku@gmail.com.

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

ERTool-0.3.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

ERTool-0.3.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file ERTool-0.3.1.tar.gz.

File metadata

  • Download URL: ERTool-0.3.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for ERTool-0.3.1.tar.gz
Algorithm Hash digest
SHA256 413e548ca85fe7ef758eb6cfe3f94f466170df27ea0c5a3a2db8ddd00f8f229d
MD5 1e4fc20be88867933c9d4a36f7a3fd46
BLAKE2b-256 0bda71ce98057bd860668aaac0c358e6df31b795f4f8f796fd0874794624e6e7

See more details on using hashes here.

File details

Details for the file ERTool-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: ERTool-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for ERTool-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dfcf9a416645a5b3c4933f7afaebdac3c0e952d5ff88ce19f7b9401d4cb4e863
MD5 7eb913e0c72b5819281cf8dbb1ecc7cb
BLAKE2b-256 0d46e547998ffcf0b3bb6cd7d543bbb232949354878304acaddea326c7a06679

See more details on using hashes here.

Supported by

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