Skip to main content

An implementation of game theory of mind in a agent based framework following the implementation of Devaine, et al. (2017).

Project description

tomsup: Theory of Mind Simulation using Python

PyPI version pip downloads Code style: black python version license github actions pytest github actions docs github coverage CodeFactor

A Python Package for Agent-Based simulations. The package provides a computational eco-system for investigating and comparing computational models of hypothesized Theory of mind (ToM) mechanisms and for using them as experimental stimuli. The package notably includes an easy-to-use implementation of the variational Bayesian k-ToM model developed by Devaine, et al. (2017). This model has been shown able to capture individual and group-level differences in social skills, including between clinical populations and across primate species. It has also been deemed among the best computational models of ToM in terms of interaction with others and recursive representation of mental states. We provide a series of tutorials on how to implement the k-ToM model and a score of simpler types of ToM mechanisms in game-theory based simulations and experimental stimuli, including how to specify custom ToM models, and show examples of how resulting data can be analyzed.

📰 News

  • v. 1.1.0
    • A speed comparison between the matlab implementation was introduced, showing the the tomsup implementation to be notably faster.
    • An extensive testsuite was introduced, for how to run it see the FAQ.
    • Code coverage was upped to 86% and code quality was raised to A.
    • A documentation site was introduced.
    • Added continiuous integration to ensure that the package always work as intended, with support for mac, windows and linux tests.
    • A new logo was introduced 🌟
  • v. 1.0.0
    • tomsup released its first version along with a preprint on psyarxiv
    • A series of tutorials was introduced to get you started with tomsup

🔧 Setup and installation

tomsup supports Python 3.6 or later. We strongly recommend that you install tomsup from pip. If you haven't installed pip you can install it from the official pip website, otherwise, simply run:

pip install tomsup 
Detailed instructions

You can also install it directly from github by simply running:

pip install git+https://github.com/KennethEnevoldsen/tomsup.git

or more explicitly:

git clone https://github.com/KennethEnevoldsen/tomsup.git
cd tomsup
pip3 install -e .

Getting Started with tomsup

To get started with tomsup we recommend the tutorials in the tutorials folder. We recommend that you start with the introduction.

The tutorials are provided as Jupyter Notebooks. If you do not have Jupyter Notebook installed, instructions for installing and running can be found here.

Tutorial Content file name Google Colab
Documentation The documentations of tomsup
Introduction a general introduction to the features of tomsup which follows the implementation in the paper paper_implementation.ipynb Open In Colab
Creating an agent an example of how you would create new agent for the package. Creating_an_agent.ipynb Open In Colab
Specifying internal states a short guide on how to specify internal states on a k-ToM agent specifying_internal_states.ipynb Open In Colab
Pscyhopy experiment An example of how one might implement tomsup in an experiment Not a notebook, but a folder, psychopy_experiment Open in Github

🤔 Issues and Usage Q&A

To ask report issues or request features, please use the GitHub Issue Tracker. Otherwise, please use the discussion Forums.

FAQ

How do I test the code and run the test suite?

tomsup comes with an extensive test suite. In order to run the tests, you'll usually want to clone the repository and build tomsup from the source. This will also install the required development dependencies and test utilities defined in the requirements.txt.

pip install -r requirements.txt
pip install pytest

python -m pytest

which will run all the test in the tomsup/tests folder.

Specific tests can be run using:

python -m pytest tomsup/tests/<DesiredTest>.py

Code Coverage If you want to check code coverage you can run the following:

pip install pytest-cov

python -m pytest--cov=.
Does tomsup run on X?

DaCy is intended to run on all major OS, this includes Windows (latest version), MacOS (Catalina) and the latest version of Linux (Ubuntu). Below you can see if DaCy passes its test suite for the system of interest. The first one indicated Linux. Please note these are only the systems DaCy is being actively tested on, if you run on a similar system (e.g. an earlier version of Linux) DaCy will likely run there as well.

Operating System Status
Ubuntu (Latest) github actions pytest ubuntu
MacOS (Catalina) github actions pytest catalina
Windows (Latest) github actions pytest windows
How is the documentation generated?

DaCy uses sphinx to generate documentation. It uses the Furo theme with a custom styling.

To make the documentation you can run:

# install sphinx, themes and extensions
pip install sphinx furo sphinx-copybutton sphinxext-opengraph

# generate html from documentations

make -C docs html

Using this Work

License

tomsup is released under the Apache License, Version 2.0.

Citing

If you use this work please cite:

@article{enevoldsen2020tomsup,
  title={tomsup: An implementation of computational Theory of Mind in Python},
  author={Enevoldsen, Kenneth C and Waade, Peter Thestrup},
  year={2020},
  publisher={PsyArXiv}
}

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

tomsup-1.1.0.tar.gz (40.0 kB view details)

Uploaded Source

Built Distribution

tomsup-1.1.0-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file tomsup-1.1.0.tar.gz.

File metadata

  • Download URL: tomsup-1.1.0.tar.gz
  • Upload date:
  • Size: 40.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for tomsup-1.1.0.tar.gz
Algorithm Hash digest
SHA256 59fd90d38faf6531a2a0f9b29e27c5d5ef60882c98262714f0a137061f9d6e51
MD5 086acd6f2c0e079ce97ebfa11831562f
BLAKE2b-256 0a098cda0b8699538e1380cae5b4ff39e57cc7028317649816ac90f0493e740f

See more details on using hashes here.

File details

Details for the file tomsup-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: tomsup-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for tomsup-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d163f3bb83fa5e97554609ae517c879a62cca208b063cdc19293d52ad1f439ec
MD5 302f0f66d6da36876833768d523e59d4
BLAKE2b-256 f4dd7f65d90ac8bcbbdef877283230bb204d2e1db54acfd23b9a13eca1c9cabb

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