<jupyter_start><jupyter_text>---title: "Evidently: Simulate Evidence Accumulation Models in Python"date: "2020-01-23"source: "jupyter"--- I've just put the finishing touches on version 0.0.1 of `Evidently` is a python package for working with evidence accumulation models.In short, it lets you do things like this:![](schurger.gif)Since I spent all that time writing a Read Me page for the [GitHub repository](https://github.com/EoinTravers/Evidently),I've reproduced it below.  Evidently Evidently  provides- Efficient functions for simulating data from a range of models.- Classes that make it easier to tweak model parameters and manage simulated data.- A consistent way to implement new models.- Visualisation, including interactive widgets for Jupyter.- Kernel density-based methods for estimating   the likelihood of real data under a given model/set of parameters,  allowing parameter estimation and model comparision.To see some of the features of Evidently in action,click the link below to launch a notebook packed full of interactive visualisations.[![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/EoinTravers/Evidently/master?filepath=dashboards%2FInteractive%20Models.ipynb) InstallationEvidently isn't on PyPI yet, but you can install it directly from GitHub:`pip install git+https://github.com/EoinTravers/Evidently`  Basic Use<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import evidently<jupyter_output><empty_output><jupyter_text>Set up a model and provide parameters<jupyter_code>model = evidently.models.Diffusion(pars=[1., .5, -.25, .8, .4], max_time=5., dt=.001)
model
model.describe_parameters()<jupyter_output><empty_output><jupyter_text>Simulate data<jupyter_code>X, responses, rts = model.do_dataset(n=1000)
X.head()
print(responses[:5]) 
print(rts[:5])<jupyter_output><empty_output><jupyter_text>VisualiseThe `evidently.viz` submodule contains a collection of `matplotlib`-based functions for visualising model simulations. Here are a few examples.<jupyter_code>ax = evidently.viz.setup_ddm_plot(model) # Uses model info to draw bounds.
evidently.viz.plot_trace_mean(model, X, ax=ax); # Plots simulations
ax = evidently.viz.setup_ddm_plot(model)
evidently.viz.plot_traces(model, X, responses, rts, ax=ax, 
                          terminate=True, show_mean=True); # Show raw data
ax = evidently.viz.setup_ddm_plot(model)
for resp in [1, -1]:
    mask = (responses == resp) # Split by response
    evidently.viz.plot_trace_mean(model, X[mask], ax=ax, label='Response: %i' % resp)
plt.legend();
mX = evidently.utils.lock_to_movement(X, rts, duration=2) # Time-lock to threshold crossing
ax = evidently.viz.setup_ddm_plot(model, time_range=(-2, 0))
evidently.viz.plot_traces(model, mX, responses, rts, ax=ax, show_mean=True);
ax = evidently.viz.setup_ddm_plot(model, time_range=(-2, 0))
for resp in [1, -1]:
    mask = responses == resp
    resp_mX = evidently.utils.lock_to_movement(X[mask], rts[mask])
    evidently.viz.plot_trace_mean(model, resp_mX, ax=ax, label='Response: %i' % resp)
plt.legend();<jupyter_output><empty_output><jupyter_text>There high-level functions can create multi-axis figures.<jupyter_code>evidently.viz.visualise_model(model, model_type='ddm', measure='means');<jupyter_output><empty_output><jupyter_text>Interactive VisualisationUsing the `ipywidgets` package, we can wrap high level visualisation functions like `accum.viz.visualise_ddm` in a call to `ipywidgets` to make them interactive.To try the interactive plots, download this repository to your own computer,or run the code in the cloud by visiting [this Binder notebook](https://mybinder.org/v2/gh/EoinTravers/Evidently/master?filepath=dashboards%2FInteractive%20Models.ipynb).[![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/EoinTravers/Evidently/master?filepath=dashboards%2FInteractive%20Models.ipynb)<jupyter_code>from ipywidgets import interact, FloatSlider
def fs(v, low, high, step, desc=''):
    return FloatSlider(value=v, min=low, max=high, step=step, description=desc, continuous_update=False)

def ddm_simulation_plot(t0=1., v=.5, z=0., a=.5, c=.1):
    model = evidently.Diffusion(pars=[t0, v, z, a, c])
    evidently.viz.visualise_model(model)
    title = 't0 = %.1f, Drift = %.1f, Bias = %.1f, Threshold = %.1f; Noise SD = %.1f' % (t0, v, z, a, c)
    plt.suptitle(title, y=1.01)

interact(ddm_simulation_plot,
         t0  = fs(1., 0, 2., .1,   't0'),
         v   = fs(.5, 0, 2., .1,   'Drift'),
         z   = fs(0., -1., 1., .1,  'Bias'),
         a     = fs(.5, 0., 2., .1,   'Threshold'),
         c   = fs(.1, 0., 1., .1,   'Noise SD'));<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup