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.

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 import simulator
sim_out = simulator(model = 'ddm', 
                    theta = [0, 1, 0.5, 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.1.tar.gz (516.1 kB view details)

Uploaded Source

Built Distributions

ssm_simulators-0.4.1-cp311-cp311-win_amd64.whl (269.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

ssm_simulators-0.4.1-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.1-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.1-cp311-cp311-macosx_11_0_arm64.whl (307.3 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

ssm_simulators-0.4.1-cp311-cp311-macosx_10_9_x86_64.whl (368.6 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

ssm_simulators-0.4.1-cp311-cp311-macosx_10_9_universal2.whl (650.2 kB view details)

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

ssm_simulators-0.4.1-cp310-cp310-win_amd64.whl (269.6 kB view details)

Uploaded CPython 3.10 Windows x86-64

ssm_simulators-0.4.1-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.1-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.1-cp310-cp310-macosx_11_0_arm64.whl (306.7 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

ssm_simulators-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl (368.1 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

ssm_simulators-0.4.1-cp310-cp310-macosx_10_9_universal2.whl (649.2 kB view details)

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

ssm_simulators-0.4.1-cp39-cp39-win_amd64.whl (272.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

ssm_simulators-0.4.1-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.1-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.1-cp39-cp39-macosx_11_0_arm64.whl (308.5 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

ssm_simulators-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl (369.7 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

ssm_simulators-0.4.1-cp39-cp39-macosx_10_9_universal2.whl (652.0 kB view details)

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

File details

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

File metadata

  • Download URL: ssm-simulators-0.4.1.tar.gz
  • Upload date:
  • Size: 516.1 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.1.tar.gz
Algorithm Hash digest
SHA256 a22da7b759408dfc3c4681eb7029017c490c69ca0d0447a7230d679a69fe5b56
MD5 ce4a85484b61a1999a93efe0cd49956c
BLAKE2b-256 a211f689297ed765408941d55a19f75e4b0d5b0f2e3401118837db48719bc571

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5b77797bd71c4f01e6e891ba7b706c76dd5d9633b865ee1eb4248869e1beaf1a
MD5 e4361c7c985d447e4d0236641f822147
BLAKE2b-256 1a5ff9598ecb05dd39156576910b6c844d637c9289a73b835916bcc54fe8fe0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 fc60e1d0679dec66a29caf0fda7509f74f0039bd51dbbae4fcbe98d0b72a91c3
MD5 58d3d4ec8fadf5b024120308300f10f3
BLAKE2b-256 f0334bf7c01b24f5e750ca1f1d9816080aa27853756c0a6bb9372f6d9a961c4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9d8befe79e12d6c695345a06ed4059da0b9cba4382236bf6b0601e4ce7a42469
MD5 8a9b0911be7380c605095a0ccf1dc401
BLAKE2b-256 99093aea0105fe61cc232033c5f480236058bfb7fcced906c09d0026853d3e12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d03ebdab730611825272ebce633d5975b2209994ac06a5c4a80d68f978066574
MD5 ea1d8a64cd45045fd95579498f070213
BLAKE2b-256 e735c434e72606aa7c13f958039c9972ac987018d0023a1713134ff6918f2eb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2e9416c1adba501fe1176a3115e2381d4fa96a7cecf03fcc4b762ad93a7ac721
MD5 b3119b91a313268f74f1a9a6262f5ed4
BLAKE2b-256 1671ff1cf7a985a80ec42d6416f541a3d655083680b743c79849d429d3d73f86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 722c5c95c1ace6b5219f9de4da2d2e20711e0c69d02c89f9933da87bbca9716d
MD5 fa0a7ecceeb257c66ffea769e0b19b33
BLAKE2b-256 70732c0d1e6c72e06da0457145371d54bd1847d468681f894a6bb86add2e353c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ff866ebdd75c0c2bb0ed8aed72cf2fed30fe9d850ba5312ae47c53eb98934d46
MD5 f5ba51f7a7ffb26286cc794ae18d7b22
BLAKE2b-256 26c264796e8f7f1c2dbc976ed0b53dc2502f0400b7c1ec5183d8d66000e78203

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 b3c43a8c53025dbbfcb2cbc1ec914a4e45c5b2e4f41b98c0635e0d0fe1a834e7
MD5 a96109e0f8491edc5a2a5484350fc922
BLAKE2b-256 734162d3e5d51eafe293e66c88b7c489253a3c4f72045208634c31c4ac91da9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f58515628f5ce4cd6d471148b02f11450bf248f946cbffafb112c25cb667b95
MD5 b14076cbc905bd06f64b83ba58e7fcb2
BLAKE2b-256 1baead00447dcea9e1af9167e9b77e20c65312476af6499e1d550b3a5cbb6c22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3eb45020ee15add5a0c69bb815e3f9f87b6abebae45be2e61e04ef72c62824d9
MD5 43de44e7928cd3b5fcb1f50827e6d6f5
BLAKE2b-256 00e1ebd836adb89a017be23c7f40e5adcb2ef40663f2df0934829441ab68301c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0c466d007486f369464131db83e596e3112b58b65a93deef1502a4de6efa3446
MD5 22472d92d7167fdb14ce7e2f1dab6122
BLAKE2b-256 8ff71fb68aa2717cb255c3fed6ac5a126c66dcb8d265fa8002cdb98fbd6a1c6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 9e4d79dfdb2c8f92566c885724f4c8c1724d258e732c2bafb807305441302889
MD5 bf4671974884b8f7234d3b9f3b25ba49
BLAKE2b-256 80fcf8406ecff927f84a6f1d45103682030877bc324ec875162c87c383e4d61a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 56d0a804eada3db30354a28e46f2f61ccd89c5371a56f2003a6e5f175dfef12c
MD5 d33eeda049564bccffe29de1bd073be7
BLAKE2b-256 9df5f589b3e2793922d94fb13b9f539f3907070a74fcd0a9e84042168c7617f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f52aa06d0b532667ec9aa8431240b7ba2a10179c19cff15e302c02af16e8985a
MD5 ca56c8216edf5e5cebf5380aa4746191
BLAKE2b-256 5dc0a98e44758afcec48be3a62dfa04406c2b4bd36c5171e6c8c02d7ad499bef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c5e5b84e892e6da4f788a692310cc3c137c0faf53c6b830b93551e4c5e83499c
MD5 ad9a1fe2558f7b970586c6e4796cab00
BLAKE2b-256 1c224c71d33a4e3c427607a45b542d5be6658043009cd09702e7a882db9d3fc9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a01e468c4730a417de57c56b72d962289ae888233b045d75e29434aeb94a6890
MD5 79a4df0b43dded25a47235c314fa0369
BLAKE2b-256 44ceddd2c04f0075599af03bf2f4cf6a6d33533b1be6da8efa9cdb25fd9e2b14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d08363bb959ff0a8a0e36178597b665172d582908dccfc96dd67d6ce96c9a530
MD5 66035e607d520bad679113adc710727f
BLAKE2b-256 6416d79e1d29f5192c57ada45e331af5828aeeb9e73373f869831e51376cf261

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.1-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 44e40f93bbcde2107a8877e77f1d6b2300e9fef162a5e75670ea8570f3abe5b9
MD5 8f44a9ea0c3adf537f8443587179bf87
BLAKE2b-256 455e439f4f7dbf2ad69d642d0a7fdbe256a44c49a3cf8c32438b6ca24e0b1898

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