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 Open with
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.1.tar.gz (40.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tomsup-1.1.1.tar.gz
Algorithm Hash digest
SHA256 076e0a05ba63eeb4c4606a7143a9a3c0b14d9c1273ae7b680438228f875dca33
MD5 3b0a0cf6326d999c7efb42ba80a723cc
BLAKE2b-256 2e56f0b690f53fd5066b7f124cbc9eb290e0acb72b4e5b97033825494d759f02

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tomsup-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c0c94878cf359e3b9a79aedca31df5b4e059902255037020248010563b3ea54
MD5 f383439083059071918f4979136ed71f
BLAKE2b-256 61f366c229a7ab144e5a3c4c90fa9ccc79131491345d79943236fcdb048d5aeb

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