agentlab.experiments.args

Functions

expand_cross_product(obj)

Expand the given object into a list of objects with all combinations of CrossProd objects.

make_ablation_study(start_point, changes[, ...])

Ablation study by modifying the start_point with only one change at a time, and restarting from the original start_point for each configuration.

make_progression_study(start_point, changes)

A kind of ablation study by changing the start_point with changes one by one.

sample_and_expand_cross_product(obj, n_samples)

This will sample first and then expand the cross product.

sample_args(obj, n_samples)

Sample the given object n_samples times.

Classes

Choice(elements[, p])

Use to specify that this will be sampled from a list of elements

CrossProd(elements)

Use to specify that this will be part of a cross product

Distribution()

Generic Class to identify that this is a distribution

Toggle()

class agentlab.experiments.args.Choice(elements, p=None)

Bases: Distribution

Use to specify that this will be sampled from a list of elements

sample(rng=<module 'numpy.random' from '/home/docs/checkouts/readthedocs.org/user_builds/agentlab/envs/latest/lib/python3.12/site-packages/numpy/random/__init__.py'>)
class agentlab.experiments.args.CrossProd(elements)

Bases: object

Use to specify that this will be part of a cross product

class agentlab.experiments.args.Distribution

Bases: ABC

Generic Class to identify that this is a distribution

sample()
class agentlab.experiments.args.Toggle

Bases: object

agentlab.experiments.args.expand_cross_product(obj: Any | list[Any])

Expand the given object into a list of objects with all combinations of CrossProd objects.

This function will recursively search for CrossProd objects in the given object and create a list of objects with all combinations of CrossProd. It searches through dataclasses and dictionaries.

Parameters:

obj – Any | List[Any], The object to expand.

Returns:

A list of objects with all combinations of CrossProd objects.

Return type:

List[Any]

agentlab.experiments.args.make_ablation_study(start_point, changes, return_cross_prod=True)

Ablation study by modifying the start_point with only one change at a time, and restarting from the original start_point for each configuration.

Parameters:
  • start_point – the starting point of the ablation study

  • changes – a list of changes to make to the start_point. Each change is either a callable or tuple containing a string identifying the path in the object to change and the value to change to. ex: (“.obs.use_html”, True)

  • return_cross_prod – return a CrossProd object or just the list

Returns:

A CrossProd object containing a list of objects with one change from start_point. If return_cross_prod is False, then it will return a list.

agentlab.experiments.args.make_progression_study(start_point, changes, return_cross_prod=True)

A kind of ablation study by changing the start_point with changes one by one.

Parameters:
  • start_point – the starting point of the study

  • changes – a list of changes to make to the start_point. Each change is either a callable or tuple containing a string identifying the path in the object to change and the value to change to. ex: (“.obs.use_html”, True)

  • return_cross_prod – return a CrossProd object or just the list

Returns:

A CrossProd object containing a list of objects with progressive changes from start_point. If return_cross_prod is False, then it will return a list.

agentlab.experiments.args.sample_and_expand_cross_product(obj: Any | list[Any], n_samples: int)

This will sample first and then expand the cross product.

agentlab.experiments.args.sample_args(obj: Any | list[Any], n_samples: int)

Sample the given object n_samples times. Each sample is a deep copy of the original object with any object of type Distribution replaced by a sample from that distribution.

Parameters:
  • obj – Any | List[Any], the object to sample

  • n_samples – int, the number of samples to generate

Returns:

A list of n_samples objects with the given object.

Return type:

List[Any]