{"id":17026460,"url":"https://github.com/daeh/computed-appraisals","last_synced_at":"2025-04-12T11:33:54.862Z","repository":{"id":170447755,"uuid":"606275225","full_name":"daeh/computed-appraisals","owner":"daeh","description":"Computed Appraisals Model. Code and data for the 2023 paper, \"Emotion prediction as computation over a generative theory of mind\"","archived":false,"fork":false,"pushed_at":"2023-06-12T20:28:46.000Z","size":9983,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T06:22:09.628Z","etag":null,"topics":["affective-computing","cognitive-science","emotional-intelligence","probabilistic-programming","psychology"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daeh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-25T02:19:52.000Z","updated_at":"2025-02-25T05:13:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"4a5c49ad-b0f8-4340-8cc4-c26cd4d83b4a","html_url":"https://github.com/daeh/computed-appraisals","commit_stats":null,"previous_names":["daeh/computed-appraisals"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daeh%2Fcomputed-appraisals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daeh%2Fcomputed-appraisals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daeh%2Fcomputed-appraisals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daeh%2Fcomputed-appraisals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daeh","download_url":"https://codeload.github.com/daeh/computed-appraisals/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248560465,"owners_count":21124661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["affective-computing","cognitive-science","emotional-intelligence","probabilistic-programming","psychology"],"created_at":"2024-10-14T07:32:49.326Z","updated_at":"2025-04-12T11:33:54.850Z","avatar_url":"https://github.com/daeh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Emotion prediction as computation over a generative theory of mind\n\n![Computed Appraisals Model](https://daeh.info/proj/houlihan2023computedappraisals/img/cam_summary.jpg)\n\n**ABSTRACT** From sparse descriptions of events, observers can make systematic and nuanced predictions of what emotions the people involved will experience. We propose a formal model of emotion prediction in the context of a public high-stakes social dilemma. This model uses inverse planning to infer a person's beliefs and preferences, including social preferences for equity and for maintaining a good reputation. The model then combines these inferred mental contents with the event to compute 'appraisals': whether the situation conformed to the expectations and fulfilled the preferences. We learn functions mapping computed appraisals to emotion labels, allowing the model to match human observers' quantitative predictions of twenty emotions, including joy, relief, guilt, and envy. Model comparison indicates that inferred monetary preferences are not sufficient to explain observers' emotion predictions; inferred social preferences are factored into predictions for nearly every emotion. Human observers and the model both use minimal individualizing information to adjust predictions of how different people will respond to the same event. Thus, our framework integrates inverse planning, event appraisals, and emotion concepts in a single computational model to reverse-engineer people's intuitive theory of emotions.\n\n## Project information\n\nThis work is described in the open access **[paper](https://daeh.info/pubs/houlihan2023computedappraisals.pdf)**.\n\nThe GitHub repository ([https://github.com/daeh/computed-appraisals](https://github.com/daeh/computed-appraisals)) provides all of the raw behavioral data, models, and analyses.\n\nThe OSF repository ([https://osf.io/yhwqn](https://osf.io/yhwqn)) provides the cached model data and the behavioral paradigms used to collect the empirical data.\n\n## Citing this work\n\nIf you use this repository, the data it includes, or build on the models/analyses, please cite the paper (NB citation given in Bib***La***Tex):\n\n```bibtex\n@article{houlihan2023computedappraisals,\n  title = {Emotion Prediction as Computation over a Generative Theory of Mind},\n  author = {Houlihan, Sean Dae and Kleiman-Weiner, Max and Hewitt, Luke B. and Tenenbaum, Joshua B. and Saxe, Rebecca},\n  date = {2023},\n  journaltitle = {Philosophical Transactions of the Royal Society A},\n  shortjournal = {Phil. Trans. R. Soc. A},\n  volume = {381},\n  number = {2251},\n  pages = {20220047},\n  doi = {10.1098/rsta.2022.0047},\n  url = {https://royalsocietypublishing.org/doi/abs/10.1098/rsta.2022.0047}\n}\n```\n\n## Contents of the project\n\n- `code` - models and analyses\n- `dataIn` - raw behavioral data collected from human observers (see the [empirical data documentation](https://github.com/daeh/computed-appraisals/tree/main/dataIn))\n- `dataOut` - cached model data (only on [OSF](https://osf.io/yhwqn))\n- `paradigms` - mTurk experiments used to collect the behavioral data in `dataIn/` (only on [OSF](https://osf.io/yhwqn))\n\n## Running the Computed Appraisal Model\n\nTo run the computed appraisals model (_cam_), you can install the dependencies necessary to regenerate the results and figures using a **(1)** [Docker container](#1-docker-container) **(2)** [conda environment](#2-conda-environment) or **(3)** [pip specification](#3-pip-specification).\n\nNB Running this model from scratch is prohibitively compute-heavy outside of a High Performance Computing cluster. The model has been cached at various checkpoints to make it easy to explore the results on a personal computer. To make use of the cached model, download and uncompress [dataOut-cached.zip](https://osf.io/37dfr/). Then place the `dataOut` directory containing the cached `*.pkl` files in the local project folder that you clone/fork from this repository (e.g. `computed-appraisals/dataOut/`) .\n\n### 1. `Docker` container\n\nRequires [Docker](https://www.docker.com/). The image includes [WebPPL](https://github.com/probmods/webppl) and [TeX Live](https://www.tug.org/texlive/).\n\nNB Docker is finicky about the cpu architecture. The example below builds an image optimized for `arm64` processors. For an example of building an image for `amd64` processors, see `.devcontainer/Dockerfile`.\n\n```bash\n### Clone git repo to the current working directory\ngit clone --branch main https://github.com/daeh/computed-appraisals.git computed-appraisals\n\n### Enter the new directory\ncd computed-appraisals\n\n### (optional but recommended)\n### Add the \"dataOut\" directory that you downloaded from OSF in order to use the cached model\n\n### Build Docker Image\ndocker build --tag camimage .\n\n### Run Container (optional to specify resources like memory and cpus)\ndocker run --rm --name=cam \\\n    --memory 12GB --cpus 4 --platform=linux/arm64 \\\n    --volume $(pwd)/:/projhost/ \\\n    camimage /projhost/code/cam_main.py --projectdir /projhost/\n```\n\nThe container tag is arbitrary (you can replace `camimage` with a different label).\n\n### 2. `conda` environment\n\nRequires [conda](https://docs.conda.io/en/latest/), [conda-lock](https://github.com/conda-incubator/conda-lock), and a local installation of [TeX Live](https://www.tug.org/texlive/). If you want to run the inverse planning models, you need to have the [WebPPL](https://github.com/probmods/webppl) executable in your `PATH` with the [webppl-json](https://github.com/stuhlmueller/webppl-json) add-on.\n\nThe example below uses the `conda-lock.yml` file to create an environment where the package versions are pinned to this project's specifications, which is recommend for reproducibility. If the lock file cannot resolve the dependencies for your system, you can use the `environment.yml` file to create an environment with the latest package versions. Simply replace the `conda-lock install ...` line with `conda env create -f environment.yml`.\n\n```bash\n### Clone git repo to the current working directory\ngit clone --branch main https://github.com/daeh/computed-appraisals.git computed-appraisals\n\n### Enter the new directory\ncd computed-appraisals\n\n### (optional but recommended)\n### Add the \"dataOut\" directory that you downloaded from OSF in order to use the cached model\n\n### Create the conda environment\nconda-lock install --name envcam conda-lock.yml\n\n### Activate the conda environment\nconda activate envcam\n\n### Run the python code\npython ./code/cam_main.py --projectdir $(pwd)\n```\n\nThe conda environment name is arbitrary (you can replace `envcam` with a different label).\n\n### 3. `pip` specification\n\nIf you use a strategy other than [conda](https://docs.conda.io/en/latest/) or [Docker](https://www.docker.com/) to manage python environments, you can install the dependencies using the `requirements.txt` file located in the root directory of the project. You need to have [TeX Live](https://www.tug.org/texlive/) installed locally. If you want to run the inverse planning models, you need to have the [WebPPL](https://github.com/probmods/webppl) executable in your `PATH` with the [webppl-json](https://github.com/stuhlmueller/webppl-json) add-on.\n\n### Note on PyTorch\n\nDifferent hardware architectures lead to very small differences in floating point operations. In our experience, setting a random seed causes `PyTorch` to initialize at the same values, but update steps of the Adam optimizer exhibit minuscule differences depending on the platform (e.g. `Intel Xeon E5` vs `Intel Xeon Gold` cores). As such, rerunning the `PyTorch` models may yield results that show small numerical differences from the cached data.\n\n## Authors\n\n- [Sean Dae Houlihan](https://daeh.info)\n- [Max Kleiman-Weiner](https://www.mit.edu/~maxkw/)\n- [Luke Hewitt](https://lukehewitt.mit.edu/)\n- [Josh Tenenbaum](https://web.mit.edu/cocosci/josh.html)\n- [Rebecca Saxe](https://saxelab.mit.edu/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaeh%2Fcomputed-appraisals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaeh%2Fcomputed-appraisals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaeh%2Fcomputed-appraisals/lists"}