A framework for running experiments on algorithms.
Project description
AlgLab
Framework for performing experiments with algorithms in Python.
This package provides a framework for building extendable and reproducible experiments with algorithms in python. This high-level workflow is to
- Specify a dataset on which to perform an experiment.
- Implement the algorithms which are to be compared.
- Implement any evaluation methods by which the algorithm outputs will be scored.
- Specify the experimental setup, including dataset and algorithm parameters.
- Run the experiments, and
- Analyse the results.
This preserves a separation between the dataset, algorithm, evaluation methods, and experimental setup. This makes it easy to extend and modify experimental setups by changing the datasets, adding new algorithms, or changing parameters.
Example
Here's a simple example of the workflow using datasets and evaluation functions already provided by alglab.
import alglab
# First, implement the algorithms that you would like to compare.
# Note that the signature of the implemented algorithms should take a dataset as the first argument,
# followed by the algorithm parameters as keyword arguments, with default values.
def kmeans(data: alglab.dataset.PointCloudDataset, k=10):
sklearn_km = KMeans(n_clusters=k)
sklearn_km.fit(data.data)
return sklearn_km.labels_
def spectral_clustering(data: alglab.dataset.PointCloudDataset, k=10):
sklearn_sc = SpectralClustering(n_clusters=k)
sklearn_sc.fit(data.data)
return sklearn_sc.labels_
# Configure the experiments. As well as the algorithms, we specify which dataset class to use,
# and the parameters for the algorithms and dataset.
#
# We also specify any functions which should be used to evaluate the algorithms, and give a
# filename in which to store the results.
experiments = alglab.experiment.ExperimentalSuite(
[kmeans, spectral_clustering],
alglab.dataset.TwoMoonsDataset,
"results/twomoonsresults.csv",
parameters={
"k": 2,
"dataset.n": np.linspace(1000, 5000, 6).astype(int),
},
evaluators=[alglab.evaluation.adjusted_rand_index],
)
def main():
# Run the experiments
experiments.run_all()
# Now, we can visualise the results
results = alglab.results.Results("results/twomoonsresults.csv")
results.line_plot("n", "running_time_s")
results.line_plot("n", "adjusted_rand_index")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alglab-1.0.0.tar.gz.
File metadata
- Download URL: alglab-1.0.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a37ad5bea1910f79fe3f2ba64e40f9aed197d9adc6b8189ec72918f5243f033
|
|
| MD5 |
9116ded80366b8186b3d919c3c290830
|
|
| BLAKE2b-256 |
1fcafda474aac93a11effbd8cbb46fc5f307a1863c241bd98763a474da86530b
|
Provenance
The following attestation bundles were made for alglab-1.0.0.tar.gz:
Publisher:
python-publish.yml on pmacg/algpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alglab-1.0.0.tar.gz -
Subject digest:
5a37ad5bea1910f79fe3f2ba64e40f9aed197d9adc6b8189ec72918f5243f033 - Sigstore transparency entry: 274026777
- Sigstore integration time:
-
Permalink:
pmacg/algpy@c986eaaa31406e59367eabf0db9a916b3b18503f -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/pmacg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c986eaaa31406e59367eabf0db9a916b3b18503f -
Trigger Event:
release
-
Statement type:
File details
Details for the file alglab-1.0.0-py3-none-any.whl.
File metadata
- Download URL: alglab-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68b2676541e269ae4bf48ce262b2eebe366350e7429656d4f5894a9187d31720
|
|
| MD5 |
1bad2ee1cb62048a8b7e42d924736c2a
|
|
| BLAKE2b-256 |
31714d91e389144b6398757c90a616581abd4c8f3d0a66b6dcaa5d0de51e1142
|
Provenance
The following attestation bundles were made for alglab-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on pmacg/algpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alglab-1.0.0-py3-none-any.whl -
Subject digest:
68b2676541e269ae4bf48ce262b2eebe366350e7429656d4f5894a9187d31720 - Sigstore transparency entry: 274026779
- Sigstore integration time:
-
Permalink:
pmacg/algpy@c986eaaa31406e59367eabf0db9a916b3b18503f -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/pmacg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c986eaaa31406e59367eabf0db9a916b3b18503f -
Trigger Event:
release
-
Statement type: