experiments_csv - experiment tracking via CSV files
Motivation
You run an experiments with various input parameters. You check various input combinations and run the experiment on each combination.
Suddenly, during one of the runs, the program crashes. You have to restart the experiment for the current and future inputs, but you do not want to repeat it for all previous inputs.
Solution
experiments_csv saves all the experiment input and output data into a CSV file. When you restart the experiment, it reads the CSV file and notes all the input combinations for which the experiment already completed. It then automatically skips these input combinations.
Installation
Basic installation:
pip install experiments-csv
Installation with plotting ability:
pip install experiments-csv[plotting]
Usage
See the demo programs in the examples folder for usage examples. In detail, you should:
- Write a function for running a single instance of the experiment. The function may take any number of arguments as inputs. It should return a dict with any number of arguments as outputs. For example:
def fair_division_algorithm(num_of_agents:int, num_of_items:int, threshold:float, criterion:str):
# ...
# Run the fair division algorithm with the given parameters
# ...
return {
"runtime": runtime,
"max_value": max(values),
"min_value": min(values)
}
- Decide what ranges you want for your input parameters, for example:
input_ranges = {
"num_of_agents": [2, 3, 4],
"num_of_items": range(2,10),
"threshold": [0.5],
"criterion": ["proportionality", "envy-freeness"]
}
- Create an Experiment object. It takes as arguments the folder for the experiment results, the experiment file name, and the folder for backups:
import experiments_csv
ex = experiments_csv.Experiment("results/", "results.csv", "results/backups")
- Run the experiment:
ex.run(fair_division_algorithm, input_ranges)
This loops over all combinations of inputs in the ranges you passed (the Cartesian product of the ranges in input_ranges), calls the single-instance function, and records the results in the given CSV file. The CSV file will have a column for every input and output (in the example: num_of_agents, num_of_items, threshold, criterion, runtime, min_value, max_value), and a single row for every run.
If the experiment stops abruptly due to an error, you can re-run the same code, and it will not repeat the experiments with the combinations of arguments it already completed - it will only run the experiments for the combinations not done yet.
If you do want to restart the experiment from scratch, either manually delete the CSV file, or use a new CSV file with a different name, or do
ex.clear_previous_results()
To log the inputs and outputs during run, you can do:
ex.logger.setLevel(logging.INFO)
Plotting
To plot the results, you can use the plot_results function, for example:
from matplotlib import pyplot as plt
experiments_csv.plot_results(plt, "results.csv", filter={"algorithm": "abc"}, xcolumn="size", ycolumn="runtime", zcolumn="bits")
See the demo programs for usage examples.
Metadata
Release files for experiments-csv 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| experiments_csv-0.6.0.tar.gz | 11.9 kB | Without provenance | Details for experiments_csv-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| experiments_csv-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for experiments_csv-0.6.0-py3-none-any.whl |
Total release size: 23.0 kB
Release files / experiments_csv-0.6.0.tar.gz
| Download URL | experiments_csv-0.6.0.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51f5e20530d12b2ec8ec6a85533dacb1b9aa98452e0bf5f1cbd82df47b75d5d1
|
|
BLAKE2b-256 checksum How to use checksums |
be6c9953f630b8db267d2a075f10a5721a6ac14e974b49522e0276ecb49c3fe9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.11
|
Release files / experiments_csv-0.6.0-py3-none-any.whl
| Download URL | experiments_csv-0.6.0-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a985dae93502e98ef20f565402a6503f0a1f8f06390619d5de1c2ae6e5a0fdc
|
|
BLAKE2b-256 checksum How to use checksums |
299b112c89f14b21c17b56a9232cfe1ec09010a1b5e3e6e7ff115bc4a3d36c18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.11
|
Security for experiments-csv 0.6.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.