Skip to main content

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()

Image

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()

Image

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

Image

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


Download files

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

Source Distribution

decision_tool-1.0.3.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

decision_tool-1.0.3-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file decision_tool-1.0.3.tar.gz.

File metadata

  • Download URL: decision_tool-1.0.3.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

Hashes for decision_tool-1.0.3.tar.gz
Algorithm Hash digest
SHA256 59fbc057df24473236ccd282c80cd5f49c6abbe7a79de463217ecd382137af7d
MD5 e3ce661db75356ce917355aa71d34de1
BLAKE2b-256 2afb180e8e5dcd732e10074e55ec4ac0e55102e007665c8ecc0b1cf4b9dc2dd6

See more details on using hashes here.

File details

Details for the file decision_tool-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: decision_tool-1.0.3-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

Hashes for decision_tool-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 19fd2b81fc8baf0d0e0184fe7417d7d25dc9963533658a71254cd8f9a427fa18
MD5 cfa0177bd3b6762d26b0616211698979
BLAKE2b-256 49f406d6136bc3637185b8498f620c25157a319fa012491a06d55d779d02d86f

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