Decision analysis package with solution and visualization.
Project description
Project description
Decision-tool is a simple yet effective decision analysis tool. Solves and visualizes Trees with recursive algorithm.
Usage
Decision trees are constructed using Tree class. it takes nested structure and returns a Tree instance. In the nested structure, dictinary represents decision, List represents discrete probability distribution and tuple represents possible outcome of a discrete probability distribution, scipy.stats can be used for continous probability distribution:
example_tree = Tree({"option 1":25,
"option 2":[(.4,20,"result 1"), (.3,21,"result 2"), (.3,stats.norm(1,1),"result 3")]
})
example_tree.fig().show()
Consider the example: You have 2 options as quit the job and not quit. if you quit, you will get a bonus of 8000. If you do not quit, you will promote to manager with a probability of 0.3, If you then quit, will get 16000, If you do not, you will get a random payoff distributed normally with mean 12000 and standart deviation of 1000. If you do not quit at the begining and do not promote, your PV will be normal random variable with mean 10000 and standart deviation of 3000.
job_decision = Tree({
"quit":8e3,
"do not quit":[(0.3,
{"quit":16e3,
"do not quit":stats.norm(12e3,1e3)
}
,"promote"),
(0.7, stats.norm(10e3,3e3),"do not promote")
]
})
job_decision.fig().show()
The method solve returns a Tree instance that only contains optimal solutions.
solution = job_decision.solve()
print("optimal expected monetary value:" ,solution.mean,"variance:",solution.var)
solution.fig().show()
optimal expected monetary value: 11800.0 variance: 13860000.0
For indexing, order decision names and event names:
print("Variance of not quiting and not getting a promote ",
solution["do not quit","do not promote"].var)
Variance of not quiting and not getting a promote 9000000.0
Save and load decision trees using save method and load_tree function.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file decision_tool-1.0.2.tar.gz.
File metadata
- Download URL: decision_tool-1.0.2.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b60688e6a76a972988c84ca0466dfa937d18a292a066b4a2b2be77ed9e2517e6
|
|
| MD5 |
3d769ef6a328c55c6b42f2dafe6f7ef5
|
|
| BLAKE2b-256 |
0d2c651ef4484195d49fe8352431bec195a337abcefe88404632043ad4fa15f7
|
File details
Details for the file decision_tool-1.0.2-py3-none-any.whl.
File metadata
- Download URL: decision_tool-1.0.2-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ad457ab2e0ffc3fdf2f0750ee11b1644e183c3f0fc272ab70bca2296148cf30
|
|
| MD5 |
cdc596bea5ae6b108239677df2b3d2c9
|
|
| BLAKE2b-256 |
fb262f30ed3bc09578c9c3d8f1e825ea1623781332a692c1cf0df097abd0f284
|