Skip to main content

dataprob

docs/badges/tests-badge.svg docs/badges/coverage-badge.svg

dataprob was designed to allow scientists to easily fit user-defined models to experimental data. It allows maximum likelihood, bootstrap, and Bayesian analyses with a simple and consistent interface.

Design principles

  • ease of use: Users write a python function that describes their model, then load in their experimental data as a dataframe.

  • dataframe centric: Uses a pandas dataframe to specify parameter bounds, guesses, fixedness, and priors. Observed data can be passed in as a dataframe or numpy vector. All outputs are pandas dataframes.

  • consistent experience: Users can run maximum-likelihood, bootstrap resampling, or Bayesian MCMC analyses with an identical interface and nearly identical diagnostic outputs.

  • interpretable: Provides diagnostic plots and runs tests to validate fit results.

Simple example

The following code generates noisy linear data and uses dataprob to find the maximum likelihood estimate of its slope and intercept. Run on Google Colab.

import dataprob
import numpy as np

# Generate "experimental" linear data (slope = 5, intercept = 5.7) that has
# random noise on each point.
x_array = np.linspace(0,10,25)
noise = np.random.normal(loc=0,scale=0.5,size=x_array.shape)
y_obs = 5*x_array + 5.7 + noise

# 1. Define a linear model
def linear_model(m=1,b=1,x=[]):
    return m*x + b

# 2. Set up the analysis. 'method' can be "ml", "mcmc", or "bootstrap"
f = dataprob.setup(linear_model,
                   method="ml",
                   non_fit_kwargs={"x":x_array})

# 3. Fit the parameters of linear_model model to y_obs, assuming uncertainty
#    of 0.5 on each observed point.
f.fit(y_obs=y_obs,
      y_std=0.5)

# 4. Access results
fig = dataprob.plot_summary(f)
fig = dataprob.plot_corner(f)
print(f.fit_df)
print(f.fit_quality)

The plots will be:

data.plot_summary result data.plot_corner result

The f.fit_df dataframe will look something like:

index

name

estimate

std

low_95

high_95

…

prior_std

m

m

5.009

0.045

4.817

5.202

…

NaN

b

b

5.644

0.274

4.465

6.822

…

NaN

The f.fit_quality dataframe will look something like:

name

description

is_good

value

num_obs

number of observations

True

25.000

num_param

number of fit parameters

True

2.000

lnL

log likelihood

True

-18.761

chi2

chi^2 goodness-of-fit

True

0.241

reduced_chi2

reduced chi^2

True

1.192

mean0_resid

t-test for residual mean != 0

True

1.000

durbin-watson

Durbin-Watson test for correlated residuals

True

2.265

ljung-box

Ljung-Box test for correlated residuals

True

0.943

Installation

We recommend installing dataprob with pip:

pip install dataprob

To install from source and run tests:

git clone https://github.com/harmslab/dataprob.git
cd dataprob
pip install .

# to run test-suite
pytest --runslow

Examples

A good way to learn how to use the library is by working through examples. The following notebooks are included in the dataprob/examples/ directory. They are self-contained demonstrations in which dataprob is used to analyze various classes of experimental data. The links below launch each notebook in Google Colab:

Documentation

Full documentation is on readthedocs.

Metadata

Release files for dataprob 0.9.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dataprob 0.9.4
File Size Uploaded Provenance
dataprob-0.9.4.tar.gz 50.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dataprob 0.9.4
File Interpreter ABI Platform
dataprob-0.9.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 112.6 kB

Release files / dataprob-0.9.4.tar.gz

Download URL dataprob-0.9.4.tar.gz
Size 50.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ad29a3498e5e90f2cca7435e32beff665065eb41d938e534df601e4352c8b38b
BLAKE2b-256 checksum
How to use checksums
5e6168dcf223120b8d4feceff927e850f48aa54fc877ae81b8c3e3e656fb5378
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / dataprob-0.9.4-py2.py3-none-any.whl

Download URL dataprob-0.9.4-py2.py3-none-any.whl
Size 62.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
58ad959ed297c9346ea27c3c5e84d41768b2e4a6c9f9b96ca769e73f5cd98223
BLAKE2b-256 checksum
How to use checksums
b6e060a95ddf57e74c18fb56242cb651826f281d849d04ffde090519c4fbed11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Security for dataprob 0.9.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page