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.5.1.tar.gz (532.1 kB view details)

Uploaded Source

Built Distributions

ssm_simulators-0.5.1-cp311-cp311-win_amd64.whl (270.5 kB view details)

Uploaded CPython 3.11 Windows x86-64

ssm_simulators-0.5.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.5.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.5.1-cp311-cp311-macosx_11_0_arm64.whl (308.5 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

ssm_simulators-0.5.1-cp311-cp311-macosx_10_9_x86_64.whl (369.7 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

ssm_simulators-0.5.1-cp311-cp311-macosx_10_9_universal2.whl (651.1 kB view details)

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

ssm_simulators-0.5.1-cp310-cp310-win_amd64.whl (271.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

ssm_simulators-0.5.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.5.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.5.1-cp310-cp310-macosx_11_0_arm64.whl (308.1 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

ssm_simulators-0.5.1-cp310-cp310-macosx_10_9_x86_64.whl (369.5 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

ssm_simulators-0.5.1-cp310-cp310-macosx_10_9_universal2.whl (650.5 kB view details)

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

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

Uploaded CPython 3.9 Windows x86-64

ssm_simulators-0.5.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.5.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.5.1-cp39-cp39-macosx_11_0_arm64.whl (309.9 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

ssm_simulators-0.5.1-cp39-cp39-macosx_10_9_x86_64.whl (371.0 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

ssm_simulators-0.5.1-cp39-cp39-macosx_10_9_universal2.whl (653.3 kB view details)

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

File details

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

File metadata

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

File hashes

Hashes for ssm-simulators-0.5.1.tar.gz
Algorithm Hash digest
SHA256 4ad4e5e0cc782647dae9b87901c1d429b2e051d4fc46a6304436c22d32653268
MD5 d3df30ea5049cc22bc282ac87ce0b8fa
BLAKE2b-256 19393001e5c6d9a1b33d5fb9c083fa5ba08abc60f8fa250e29621962ec1e19c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1c6c738a2f1107db95e16b419dccd18a28f1bc857fd40125a1ac5f5beba4a442
MD5 4e235cf2c7720b865ef9d8a6c47d1751
BLAKE2b-256 3f2fb107e4a0079680588dd0ea8d3246555e5dd3a595837d173ac607b9cb0db9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 e2ca41db2518c8e53995517bda1df3d168dbe63126cb99c4dbc55fd7d4e1036a
MD5 724069f88b55e6062778f31eaefe1e33
BLAKE2b-256 77939abc6e10abf7fc9706a77370499cda4cc08d85cef7d6f7cd8b71f3554bd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ae2d6e6d3913932eed2eb50b98b93d23d439afd3eee8584425a95d43bf4eb174
MD5 9869150b2b7bcf44af3f8a6520ccdfa2
BLAKE2b-256 5de18f34388660a3ff9ece9ea394a889b5262ba2fec468bba1b4a466cdee8ccf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e74c9f064009514a703aa7029f957b56930301a780dc7881031b765a730dddd7
MD5 511f3e93a5af4ccf596df2b7dc743a57
BLAKE2b-256 7c736de053a5fe3e63cbb1d6cbb1026efc80e2975e6846b39eeb1bcfc433e13b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b755c6141395b61950e73a6c7bcd81b97b5a18431f5d0cd2d8a4dab1a6227c17
MD5 0355032a7ac4f2dc0ddf72a8d2711b43
BLAKE2b-256 f07b67d6f722f4b1ccae4f65735956bea6498fef5ced5f68dc1b4118e3241704

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 71df20007d98b2d0a7978ef77d482fe75dd0ecb0eb78e060e64c0275869bdfb6
MD5 4243f521f224732da55f78150cdb6e76
BLAKE2b-256 39a6801173bd564af541777ae2d5a3f6117cf579fc913eade5282d7e090845f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f1c7a9d69774c533258fb69039c0fbcce02ea671035cabfdb9d12a0b9a965baa
MD5 4666171cdcd8385313eda937b14984a9
BLAKE2b-256 c9817e9531d2a9f6faf688813385322447290c0b72b7d09dd7fc6a36c4ae1fe2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 c5425ad906bf07ef38cb2ef21f371b380c93585e3c6a234afd9783300fef85a3
MD5 36625783524a0d109a61b9aa6be59c8a
BLAKE2b-256 ea3644a40a1e3474e50f4433c7fff1c36e5c29230662f2ae3e01f582e7393895

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a747815bfcbe1fa256c1d8362f2754c9aa3ac5991965f0aaae911ddaf3302393
MD5 41b862b090ada3446ebad70edb37bb03
BLAKE2b-256 486eb57283ca7acd20e4945b762e7523531ea37f973c19906ebe5e1391d119d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a630bb0b70dbca85ba5715cbd4a8d946436a01f4bcbad8546e7e41a755c7776
MD5 2bbc6305c071a900142b3789cd368e4e
BLAKE2b-256 f96d0d234fbdc632ecf4b397c3dda483f1d05154c098acd1f8899fdba2699545

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7a98520f757ff53c251695bb586f9fefe86bb89b692eafdbc69cd29a664ff968
MD5 50a3fad5b3a171b74e597898701c3313
BLAKE2b-256 14f675c8c81408fc00f6c484305cb7e9091c264819299261260cdfcf0ba9819a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 b02f5aeadb4625a1b2fdd64fa68e398c6bfa37f330466a131f985848a4f98e3a
MD5 04026b102e3a83e94a2b72511eda8d93
BLAKE2b-256 8126f4a93dadeea9d94842ab59233aec3681e083cb92fb30c341ee4c572ca82d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 16fbee3b21deca396a53b1b2ff00a09828e536f8cb8bebaa6af58e55896a304f
MD5 96d93f879a442405996c07a45bff7248
BLAKE2b-256 9361ab8c2fc97eb4a334885a70d9dcec3c5cc2a00cf82d81dd4351981af9ec0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 aad49616660dfed2d8a8aacee0a5af19ed4fdafcecf9ef7e60ee9d47ff1aef99
MD5 799564bc809e2dedd4669311f996796f
BLAKE2b-256 c4c5c0bc51f3e914a2e6bb1e52d114edf86381aecad19c50e41047401fccf192

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e5e4c3f584fbcb343ab0dc52f335982522eea4628aa3788ff0d3b6ace0566bb0
MD5 7ef502e7eb9f21d7bbc1ed5aa0724b81
BLAKE2b-256 5292bfed1aa0592573bc831e41e80ddc2bf3bb7fc445fa58f49d37b79020e141

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 98e93fe6a57b4eb7331f234e517b59878e870340081c08a2621b4c3c6a55815b
MD5 2d7cc319a3638131295c4ceb4a3f72f8
BLAKE2b-256 55a44edd4f9e95101f1e572ee8f2bdeebd1d83385f9bb745670e03098de8c6ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 43155d5670fd42f49ee16d32926dd693d8d80c336197263bfd76f0a9d6158b79
MD5 77a9844cd38068b67147ead17561acb9
BLAKE2b-256 7d5644b6549396d9fec60361699bc8e629c87f58599b536c58ffaaac8110f991

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.5.1-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 3eb13162c836d6836de10dea05255ab30add73ca9102fe396bdd47363826165c
MD5 b84e3ea9e636db00a3069d123ef87846
BLAKE2b-256 feeeebf20bd0d22d7707ab7bc8c18ce5c2aa4c81ac1feccb7495ae3f8509b898

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