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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.11 Windows x86-64

ssm_simulators-0.4.9-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.9-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.9-cp311-cp311-macosx_11_0_arm64.whl (308.5 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

ssm_simulators-0.4.9-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.4.9-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.4.9-cp310-cp310-win_amd64.whl (271.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

ssm_simulators-0.4.9-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.9-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.9-cp310-cp310-macosx_11_0_arm64.whl (308.1 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

ssm_simulators-0.4.9-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.4.9-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.4.9-cp39-cp39-win_amd64.whl (273.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

ssm_simulators-0.4.9-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.9-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.9-cp39-cp39-macosx_11_0_arm64.whl (309.9 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

ssm_simulators-0.4.9-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.4.9-cp39-cp39-macosx_10_9_universal2.whl (653.2 kB view details)

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

File details

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

File metadata

  • Download URL: ssm-simulators-0.4.9.tar.gz
  • Upload date:
  • Size: 532.0 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.4.9.tar.gz
Algorithm Hash digest
SHA256 473791e63cdfc4bb63cd8910f04e2be18344c2d31254dedb7878cc57e119286b
MD5 7699944f41c905b5024fc6709544d0ef
BLAKE2b-256 7482368064bfc62434602dd5cb1ab895c66f8322b83a5682801589739cc9217e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8cf28c07ca1693f7a4ef56b27b951e24bfcab4b108d54cd3e87e497e9b41e548
MD5 0b6646607812a95c14af45cbaaa93d54
BLAKE2b-256 be338924b1831fc9a633671c6f76228a27594c44c2f4365d530df6066793cbb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 dc1e3d296355b92091761beb7aea3a65a31d81fc299f6e3794f25e273e9cb079
MD5 f831c74f230420aebe7595d8901f008f
BLAKE2b-256 8952baf495bc4774016abc8dcfdc4cd830f536380f4bb4c310a54994cb94e7e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c136bde10dc5cabdb7d6e8feeb7204d3239d43e88c5ac6be2ba4bf6b26699f27
MD5 3f57cf194608873678dbc7711ec32a0e
BLAKE2b-256 cb2f9ce6ae6d4399b0cb90fb5612f67a6dff2ffdc202f9118d216b97704dd867

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 83b7ab0d8ee1dcef731c1748b4f679b05e2883bad8532e35efb0f50196fc41dc
MD5 ddd8cafab7fa0b55c5e83a2cf4b248f3
BLAKE2b-256 39cb8c8d270af4b8b78c5df0fe931cff1d8c683988966490bd410dbf517555de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b3fcbbee7411f125d82ec87e070fab6e2008de0ae39fce7ef143106fcbb8fcce
MD5 3a9628adc5a5ae3bc6d1f795372443d9
BLAKE2b-256 3c9d2388c5727c66df2878a7e08fd43823cbbec9eeaf191ce51ab7168abd1435

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a67ff14f17c14655d74d96fef5cdc8e6efd7029a200f174a47d4ba4277be4a0e
MD5 ce41e0b6ede8c2580bd5b36042bc7016
BLAKE2b-256 1f5b4a171a66c357127c333d09b5e0e5ca2387ee49ebe1126a7e3c64159268e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c5aa8da009102504158a9d220a0ccb2e808d3afd1a7feb41781efdb921754b4d
MD5 f5d4fd977ba44405761caf0670c2a4fc
BLAKE2b-256 e509563d3911b0cd2c5beb1fc2015856cbf6624f661789950343178c48c2e0f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 9142a081a83a5953ad1edb42a7fa40103cb34205d7b9d67d515448a1d8706a1e
MD5 018a5c5154d8672c48a7a14958154e5a
BLAKE2b-256 30c0f86f3ad2e2400e15e1a3f8b00efb86c7f35d78c021a197ee168c19434fe4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7b0a5da65ddf7aef5b59e81d4b33a61c012854e0af49ea60364b793d3fb90be
MD5 1937940615cec71ed52fdf14987b4159
BLAKE2b-256 df9feb2b720dfb718bd0fde9d0e773d65012f85f17356788408f71da0ba35622

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9cbe1b8a6b9aa5b7265dae29fc6726227d43780cb42c272bd743db5d61a1985d
MD5 b1ae3ec9f4d6e33ad7cf08ccf4708b83
BLAKE2b-256 b670c003126a8de422a557403cd96e11d0b66ff2bb6fc65dbef888a2e44a4fbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 28021bdbc0b55b8aa559336df14655cc881a04b0907e614bd61eb4a39b9f243c
MD5 c18fe4789dfeddf2700f5c93d3f99749
BLAKE2b-256 7c5a8089909d080625c726da2a5dd2dfe656032bbd075585172fc91062a78f92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d54769beb940a0e97674281d0c9489cf130d7107c1912ae5fc7fbe010bd006ae
MD5 c07693c5dfedec577eaa8847bc6e59ec
BLAKE2b-256 f17a939ce332f599e0f5f58a5409062a6b1e486c48a57350d5df1b028bde0fc4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 299e7e5891cea63dad4481063fa8bedde6769f1950a0e1122a6390c9c9dceaed
MD5 5161bcb86a83d68e5f6a06155f672084
BLAKE2b-256 328832696b2020cc7e1fdd3b24770bcea17be57b136f8a43ee31fc3cdd21e601

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 043f4197720c7122e79aed406790855c8a6814abd86a4ca40543929fb2b9a72d
MD5 c68e75794d72838fe2e6ef9c5b2ee083
BLAKE2b-256 df1b12c1ed9d03e0042a39b568dfad2a5fb802a3c43a3c49a70fa99752f68303

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8dcac3f40522e0db29b70c361b784dff71ac5bd67a003d01166224a6b61f4f98
MD5 8da06829fd9aec02bd58379f662598c1
BLAKE2b-256 821b0194c253f5148116a431d607815520cc63a7669a86f6dd05ae9b2173d7e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 649dd5599d5cedffa5e1d69f2a07d018bc8435585559575afa8ebf64e4cc64f9
MD5 f60556ce549cc51bc4f65a470b018a37
BLAKE2b-256 faa63dbd637b8c9f5223a8297a46f6813daf7de64e5c216477bf48e19c527b4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 25b399844fa0c813affebdd090eaffbe6e61f36a10f533d6712c0e23d8bf91b8
MD5 d866d98d56789376941856ed5e06d12a
BLAKE2b-256 7adac5a444bca0c2d85fe3d225f0b2d31fea6c0ca918b7b4d1c933f8cc37c02c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ssm_simulators-0.4.9-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 f61eb048c04ec092f6001e377d5f06090792288bf6bf5d67b13bc33434bf92a9
MD5 f64fbc8f486026fb6973ed9a24abd6f2
BLAKE2b-256 209067ddebfbbe4516b31f6bfad857572a319c229e5bf5829abada35e06755f3

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