Skip to main content

sweep numerical experiment parameters and collect results in a Pandas table

Project description

Experiment Sweep

Helper functions for sweeping experiment parameters and collating data. Useful for Monte Carlo simulations.

Usage

Basic example

from expsweep import combination_experiment

def exp(a, b, c):
    return {
        'sum': a + b + c
    }
    
result = combination_experiment(
    exp,
    a=[1, 2, 3, 4],
    b=[1, 2, 3, 4],
    c=[1, 2, 3, 4],
    cpu_count=32
)

"""
result
    a  b  c  sum
0   1  1  1    3
1   1  1  2    4
2   1  1  3    5
3   1  1  4    6
4   1  2  1    4
.. .. .. ..  ...
59  4  3  4   11
60  4  4  1    9
61  4  4  2   10
62  4  4  3   11
63  4  4  4   12
"""

Monte Carlo Simulation with Seaborn Plotting

from expsweep import combination_experiment

# monte carlo simulation for 3 algorithms
def exp(snr):
    sample_data = generate_samples(...)

    our_error = our_method(snr, sample_data)
    guizar_error = guizar_method(snr, sample_data)
    ginsburg_error = ginsburg_method(snr, sample_data)
    
    return {
        'Ours': our_error,
        'Guizar': guizar_error,
        'Ginsburg': ginsburg_error
    }
    
result = combination_experiment(
    exp,
    snr=np.linspace(-40, -15, 10),
    iterations=50
    category_name='method',
    value_name='error'
)

import seaborn as sns
plot = sns.lineplot(
    data=result,
    x='snr',
    y='error',
    hue='method',
    style='method',
)
    

Troubleshooting

AttributeError: Can't pickle local object ...

Define the variable in question as a global

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

expsweep-0.0.1.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file expsweep-0.0.1.tar.gz.

File metadata

  • Download URL: expsweep-0.0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.5

File hashes

Hashes for expsweep-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3166894f8010922b22b74ab3cf3228fd1b4dd7af74d1591ed39da27e1fb366ac
MD5 6eb676579b86dd4ae7d4c5486925ae73
BLAKE2b-256 cd42da0522a594d53a916c77331a36476b3ab2b15f607f994e6dce5e86983ca0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page