Skip to main content

SSMS is a package collecting simulators and training data generators for a bunch of generative models of interest in the cognitive science / neuroscience and approximate bayesian computation communities

Project description

SSMS (Sequential Sampling Model Simulators)

Python Package which collects simulators for Sequential Sampling Models.

Find the package documentation here.

PyPI PyPI_dl Code style: black License: MIT

Quick Start

The ssms package serves two purposes.

  1. Easy access to fast simulators of sequential sampling models
  2. Support infrastructure to construct training data for various approaches to likelihood / posterior amortization

We provide two minimal examples here to illustrate how to use each of the two capabilities.

Install

Let's start with installing the ssms package.

You can do so by typing,

pip install git+https://github.com/AlexanderFengler/ssm_simulators

in your terminal.

Below you find a basic tutorial on how to use the package.

Tutorial

# Import necessary packages
import numpy as np
import pandas as pd
import ssms

Using the Simulators

Let's start with using the basic simulators. You access the main simulators through the ssms.basic_simulators.simulator function.

To get an idea about the models included in ssms, use the config module. The central dictionary with metadata about included models sits in ssms.config.model_config.

# Check included models
list(ssms.config.model_config.keys())[:10]
['ddm',
 'ddm_legacy',
 'angle',
 'weibull',
 'levy',
 'levy_angle',
 'full_ddm',
 'ornstein',
 'ornstein_angle',
 'ddm_sdv']
# Take an example config for a given model
ssms.config.model_config['ddm']
{'name': 'ddm',
 'params': ['v', 'a', 'z', 't'],
 'param_bounds': [[-3.0, 0.3, 0.1, 0.0], [3.0, 2.5, 0.9, 2.0]],
 'boundary': <function ssms.basic_simulators.boundary_functions.constant(t=0)>,
 'n_params': 4,
 'default_params': [0.0, 1.0, 0.5, 0.001],
 'hddm_include': ['z'],
 'nchoices': 2}

Note: The usual structure of these models includes,

  • Parameter names ('params')
  • Bounds on the parameters ('param_bounds')
  • A function that defines a boundary for the respective model ('boundary')
  • The number of parameters ('n_params')
  • Defaults for the parameters ('default_params')
  • The number of choices the process can produce ('nchoices')

The 'hddm_include' key concerns information useful for integration with the hddm python package, which facilitates hierarchical bayesian inference for sequential sampling models. It is not important for the present tutorial.

from ssms.basic_simulators.simulator import simulator
sim_out = simulator(model = 'ddm', 
                    theta = {'v': 0, 
                             'a': 1,
                             'z': 0.5,
                             't': 0.5,
                    },
                    n_samples = 1000)

The output of the simulator is a dictionary with three elements.

  1. rts (array)
  2. choices (array)
  3. metadata (dictionary)

The metadata includes the named parameters, simulator settings, and more.

Using the Training Data Generators

The training data generators sit on top of the simulator function to turn raw simulations into usable training data for training machine learning algorithms aimed at posterior or likelihood armortization.

We will use the data_generator class from ssms.dataset_generators. Initializing the data_generator boils down to supplying two configuration dictionaries.

  1. The generator_config, concerns choices as to what kind of training data one wants to generate.
  2. The model_config concerns choices with respect to the underlying generative sequential sampling model.

We will consider a basic example here, concerning data generation to prepare for training LANs.

Let's start by peeking at an example generator_config.

ssms.config.data_generator_config['lan']['mlp']
{'output_folder': 'data/lan_mlp/',
 'dgp_list': 'ddm',
 'nbins': 0,
 'n_samples': 100000,
 'n_parameter_sets': 10000,
 'n_parameter_sets_rejected': 100,
 'n_training_samples_by_parameter_set': 1000,
 'max_t': 20.0,
 'delta_t': 0.001,
 'pickleprotocol': 4,
 'n_cpus': 'all',
 'kde_data_mixture_probabilities': [0.8, 0.1, 0.1],
 'simulation_filters': {'mode': 20,
  'choice_cnt': 0,
  'mean_rt': 17,
  'std': 0,
  'mode_cnt_rel': 0.9},
 'negative_rt_cutoff': -66.77497,
 'n_subruns': 10,
 'bin_pointwise': False,
 'separate_response_channels': False}

You usually have to make just few changes to this basic configuration dictionary. An example below.

from copy import deepcopy
# Initialize the generator config (for MLP LANs)
generator_config = deepcopy(ssms.config.data_generator_config['lan']['mlp'])
# Specify generative model (one from the list of included models mentioned above)
generator_config['dgp_list'] = 'angle' 
# Specify number of parameter sets to simulate
generator_config['n_parameter_sets'] = 100 
# Specify how many samples a simulation run should entail
generator_config['n_samples'] = 1000

Now let's define our corresponding model_config.

model_config = ssms.config.model_config['angle']
print(model_config)
{'name': 'angle', 'params': ['v', 'a', 'z', 't', 'theta'], 
'param_bounds': [[-3.0, 0.3, 0.1, 0.001, -0.1], [3.0, 3.0, 0.9, 2.0, 1.3]], 
'boundary': <function angle at 0x11b2a7c10>, 
'n_params': 5, 
'default_params': [0.0, 1.0, 0.5, 0.001, 0.0], 
'hddm_include': ['z', 'theta'], 'nchoices': 2}

We are now ready to initialize a data_generator, after which we can generate training data using the generate_data_training_uniform function, which will use the hypercube defined by our parameter bounds from the model_config to uniformly generate parameter sets and corresponding simulated datasets.

my_dataset_generator = ssms.dataset_generators.data_generator(generator_config = generator_config,
                                                              model_config = model_config)
n_cpus used:  6
checking:  data/lan_mlp/
training_data = my_dataset_generator.generate_data_training_uniform(save = False)
simulation round: 1  of 10
simulation round: 2  of 10
simulation round: 3  of 10
simulation round: 4  of 10
simulation round: 5  of 10
simulation round: 6  of 10
simulation round: 7  of 10
simulation round: 8  of 10
simulation round: 9  of 10
simulation round: 10  of 10

training_data is a dictionary containing four keys:

  1. data the features for LANs, containing vectors of model parameters, as well as rts and choices.
  2. labels which contain approximate likelihood values
  3. generator_config, as defined above
  4. model_config, as defined above

You can now use this training data for your purposes. If you want to train LANs yourself, you might find the LANfactory package helpful.

You may also simply find the basic simulators provided with the ssms package useful, without any desire to use the outputs into training data for amortization purposes.

END

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

ssm-simulators-0.4.4.tar.gz (518.2 kB view details)

Uploaded Source

Built Distributions

ssm_simulators-0.4.4-cp311-cp311-win_amd64.whl (269.7 kB view details)

Uploaded CPython 3.11 Windows x86-64

ssm_simulators-0.4.4-cp311-cp311-musllinux_1_1_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

ssm_simulators-0.4.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

ssm_simulators-0.4.4-cp311-cp311-macosx_11_0_arm64.whl (307.8 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

ssm_simulators-0.4.4-cp311-cp311-macosx_10_9_x86_64.whl (369.1 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

ssm_simulators-0.4.4-cp311-cp311-macosx_10_9_universal2.whl (650.7 kB view details)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

ssm_simulators-0.4.4-cp310-cp310-win_amd64.whl (270.1 kB view details)

Uploaded CPython 3.10 Windows x86-64

ssm_simulators-0.4.4-cp310-cp310-musllinux_1_1_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

ssm_simulators-0.4.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

ssm_simulators-0.4.4-cp310-cp310-macosx_11_0_arm64.whl (307.2 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

ssm_simulators-0.4.4-cp310-cp310-macosx_10_9_x86_64.whl (368.6 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

ssm_simulators-0.4.4-cp310-cp310-macosx_10_9_universal2.whl (649.7 kB view details)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

ssm_simulators-0.4.4-cp39-cp39-win_amd64.whl (273.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

ssm_simulators-0.4.4-cp39-cp39-musllinux_1_1_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

ssm_simulators-0.4.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

ssm_simulators-0.4.4-cp39-cp39-macosx_11_0_arm64.whl (308.9 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

ssm_simulators-0.4.4-cp39-cp39-macosx_10_9_x86_64.whl (370.2 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

ssm_simulators-0.4.4-cp39-cp39-macosx_10_9_universal2.whl (652.5 kB view details)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file ssm-simulators-0.4.4.tar.gz.

File metadata

  • Download URL: ssm-simulators-0.4.4.tar.gz
  • Upload date:
  • Size: 518.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for ssm-simulators-0.4.4.tar.gz
Algorithm Hash digest
SHA256 d7df33b88a2c77fa61a4e79cbb54a8b419dddf9f67b820576d5aebae807f5a13
MD5 aba90a21b4c04df87ea0d6f79fa3c053
BLAKE2b-256 a2657f830371c36a5e13483c56b4f9f2a5ecc304315c5d3a0fec2eef6a027452

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 78d8bc9fc349323e8b8b7f273a1b9803251f3525696b9e45ac5a1fdb101df99c
MD5 3fa39ff9dd1622d57b7408a8bb407c77
BLAKE2b-256 7a85656f86bdf907e1bc7fec9258023508552a0b73614de2424f2ea9745a7750

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 cc038d841249225f252a771262b249650752d152b57966d09200186dfa1f6b83
MD5 1f3036975d6769c5bf69e84d59459683
BLAKE2b-256 f23bd75ef601bf6a9c2562dbd6c0a04f2f29dac94f78326af6f9a83eeb8673fc

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c46a7bf0ada2991c429b6c72a5f31d1c00fb4244cda28762693b3f9be248b65
MD5 aadfddad78e8afe6bad1caa8b779f9bc
BLAKE2b-256 885210900bf527994612846091d80c0759c934beff1ab7b7728c5c8b1eca1378

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d615395ad9f449bda228554af253d0a82a8d36197318188306a4f1dc9361fae2
MD5 4eafeb5a18b02b4dcb32d3af370429dc
BLAKE2b-256 430cf3f61fea0912035f0faed179c1e68d7eb5c8b2965b8d697f5ed2b2757a1c

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b2e71b7487a17496dd25941afad1aaf7f75fc7c8f66c80b0d6fc5320b3ba6940
MD5 68264d40255a5df8c09c393e9ae8b5fe
BLAKE2b-256 4abb19a947c5f905a954981cf1dd975a1c6a48f42c1d06c5babe1812d40755ea

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 b4d36ecfda6aa6acdda35926430156490c03ad42745a2520f9c5fb6574652e8e
MD5 14e7ab6912ac8e3fa01ce9fb9046809b
BLAKE2b-256 29cb92b8f094fa04411ef858e4ea906bdcda99a3e94c637478d410f9ca8a50a5

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 37db278909612af4474fc9a2ff52f1b09427b254c7cf282f671c46e523036f72
MD5 9ade527381edbae77c9103d06f418e46
BLAKE2b-256 6ee0cc40ecf080b1c791b9ed8c6e15d58249163c37b5f7296f5f50de465970d3

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 403e9eabc1552cecb0d19d9e278ab1a6379758fb939f67e5a88201781c709c83
MD5 73c444ce126d989fb441a3de274ec131
BLAKE2b-256 fc44c40df4cd459bd55cf85a6de82769e959b46ca9e90cce5ee281c0ec0756cc

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fe91cd5d346bf98e2fd54acce2b349dadc428dd16d688c947ff234074c0c4328
MD5 0e1b88c61321abdd6fca61d2c736e39c
BLAKE2b-256 21a10ecd62170e8abacc72b224117f4d62704da2641127351455d4566dfe1f77

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6223288c16b5de4f0870ee572c403ac012cccf42ab970370c56e021dde484eac
MD5 d833edbe285338ce29533ea6819ff5c7
BLAKE2b-256 0eae9f794d6b579610f508fae02241a244149decce51c33b418dd14d25e7e744

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3e99716e30d101f58c3a6fc350e0d19ce1887be9637e215491670a415ed24f63
MD5 6077eaa009e9ae4678d7d417ffa42072
BLAKE2b-256 ee4f98bee548d5f753a966355c1a783e024bafb7c238ff036cacc9a44cc4609e

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 84aa3f52a744cc2fea527e4a9d260902c71fab1761bd740bbbc59af98872b779
MD5 27e3db900ee65c989cbbef1ece486781
BLAKE2b-256 cbdd79c0ab851cea50c5d024265337ee2266a83f4c4368e359e91d93758a4ebc

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8eb4fa554163dd62f530388bc07b94d1ab759903ea4b8a9d002fefe441ae1f1d
MD5 4c9fefb96ac284c06d98b2612d19e682
BLAKE2b-256 ebe48f0fa7d34b12a8f0f29a3095adcc8772aec09ed701c5625efeaad0f86260

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 156b7c3774085695f3c473c1c9638a0ee1cc0cafe7e3b8d3953e619263305991
MD5 ec387c68de82db1f2c5a95e5f611af7b
BLAKE2b-256 1d03a1c171244d513701ee849c738943fd1ba470991b238fb7715230f7f8055a

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 37dd3506b728a1ca31753ffb74b38326e24aff9481e03c6f1bc1dc4a525f382b
MD5 135f3085c47f76c1ee8241db5c60f3e9
BLAKE2b-256 3628e378273f3d9182eeb358433bf7be0eb90a2b2dfb77b80754969326ae692a

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e4bf03f7f374bbb5854c14605c2ca1a8b26290cfed394d5f197a31c1ce8d0eb0
MD5 10a13dbc85c9a096bf910957e6357cc4
BLAKE2b-256 010efccda984463e6b91d88fada0fe4747ca1174b41efff1d1d506cba28ed7b5

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0493c29b5c830e481ee537ef656dee715c0b4e85566e2735ec5e425437ac3978
MD5 dd103eb72d172252d0fdf71047a2ef45
BLAKE2b-256 6814e07e8f4b7631a096dc10e9e3aaced7f6013af8648a85ce0c3b8812fcd6e7

See more details on using hashes here.

File details

Details for the file ssm_simulators-0.4.4-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for ssm_simulators-0.4.4-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 70eabf13f4112ba3e8c0e306ad5593a4a550953553dc4a59062294406f7a5fb0
MD5 b86e8577df64efc7d144024894961871
BLAKE2b-256 5d7a2b86b0c71eeffa3b007ebe170b5dd1bc64a8be9ef5acc210cd2f68e3d27f

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