Skip to main content

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

  1. Specify a dataset on which to perform an experiment.
  2. Implement the algorithms which are to be compared.
  3. Implement any evaluation methods by which the algorithm outputs will be scored.
  4. Specify the experimental setup, including dataset and algorithm parameters.
  5. Run the experiments, and
  6. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alglab-1.1.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alglab-1.1.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file alglab-1.1.1.tar.gz.

File metadata

  • Download URL: alglab-1.1.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for alglab-1.1.1.tar.gz
Algorithm Hash digest
SHA256 94603be7d6b0d1ba7b9e6ae2575e5d80bc90859c26dc2f10f9d8f117b9a8961f
MD5 866bd0a6d1e7e87b4c30d3c9e287e3c8
BLAKE2b-256 ff28b9be66c64b02affb565a7dcbce78993e46521728db51ebef1a9b49c245cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for alglab-1.1.1.tar.gz:

Publisher: python-publish.yml on pmacg/algpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alglab-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: alglab-1.1.1-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.13.7

File hashes

Hashes for alglab-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f26723bb2062cd9aff2f2552e8fad0fb76723c11da6cb1d4ddb3e3543a52a8cb
MD5 2d145a492e7830342a4158c541328383
BLAKE2b-256 137a1919fdb2e01f9c9cf86ffeab85359550b019e2ab026aca60c49baa59a5ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for alglab-1.1.1-py3-none-any.whl:

Publisher: python-publish.yml on pmacg/algpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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