experiment Package

class explauto.experiment.experiment.Experiment(environment, agent)[source]

Bases: explauto.utils.observer.Observer

This class is used to setup, run and log the results of an experiment.

Parameters:
  • environment (Environment) – an environment
  • agent (Agent) – an agent
run(n_iter=-1, bg=False)[source]

Run the experiment.

Parameters:
  • n_iter (int) – Number of run iterations, by default will run until the last evaluation step.
  • bg (bool) – whether to run in background (using a Thread)
wait()[source]

Wait for the end of the run of the experiment.

stop()[source]

Stop the experiment.

fast_forward(log)[source]
evaluate_at(eval_at, testcases)[source]

Sets the evaluation interation indices.

Parameters:
  • eval_at (list) – iteration indices where an evaluation should be performed
  • testcases (numpy.array) – testcases used for evaluation
classmethod from_settings(settings)[source]

Creates a Experiment object thanks to the given settings.

class explauto.experiment.pool.ExperimentPool(settings, evaluate_at, testcases=None, same_testcases=False)[source]

Bases: object

Pool of experiments running in parallel.

Parameters:
  • settings (list) – list of settings used to create the pool of experiments.
  • evaluate_at (list) – iteration indices where an evaluation should be performed.
  • testcases (numpy.array) – specify a pre-defined testcases, by default a testcases will be generated.
  • same_testcases (bool) – whether to use the same testcases for all experiments.

The Pool will create Experiment using the from_settings() constructor for each combination of parameters given.

Note

If you set same_testcases to True the first experiment will generate a testcase used by all the others experiment. Otherwise, each experiment will generate its own testcase.

classmethod from_settings_product(environments, babblings, interest_models, sensorimotor_models, evaluate_at, testcases=None, same_testcases=False)[source]

Creates a ExperimentPool with the product of all the given settings.

Parameters:
  • environments (list of (environment name, config name)) – e.g. [(‘simple_arm’, ‘default’), (‘simple_arm’, ‘high_dimensional’)]
  • babblings – e.g. [‘motor’, ‘goal’]
  • interest_models (list of (interest model name, config name)) – e.g. [(‘random’, ‘default’)]
  • sensorimotor_models (list of (sensorimotor model name, config name)) – e.g. [(‘non_parametric’, ‘default’)]
  • evaluate_at (list of int) – indices defining when to evaluate
  • same_testcases (bool) – whether to use the same testcases for all experiments
run(repeat=1, processes=None, use_thread=False)[source]

Runs all experiments using a multiprocessing.Pool.

Parameters:
  • repeat (int) – Number of time each experiment will be repeated.
  • processes (int) – Number of processes launched in parallel (Default: uses all the availabled CPUs)
  • use_thread (bool) – Use a ThreadPool instead of a Pool. By default, tries to guess depending on the environment which one to use.
settings[source]

Returns a copy of the list of all the settings used.

logs[source]

Returns the list of ExperimentLog.

Note

The logs will be returned as a vector if repeat was set as one in the run() method else it will be a matrix where each rows represents the n repetitions of an experiment.

class explauto.experiment.log.ExperimentLog(conf, expl_dims, inf_dims)[source]

Bases: object

logs[source]
add(topic, message)[source]
pack(topic_dims, t)[source]

Packs selected logs into a numpy array :param list topic_dims: list of (topic, dims) tuples, where topic is a string and dims a list dimensions to be packed for that topic :param int t: time indexes to be packed

axes_limits(topic_dims)[source]
data_t(topic_dims, t)[source]
scatter_plot(ax, topic_dims, t=None, ms_limits=True, **kwargs_plot)[source]

2D or 3D scatter plot.

Parameters:
  • ax (axes) – matplotlib axes (use Axes3D if 3D data)
  • topic_dims (tuple) – list of (topic, dims) tuples, where topic is a string and dims is a list of dimensions to be plotted for that topic.
  • t (int) – time indexes to be plotted
  • kwargs_plot (dict) – argument to be passed to matplotlib’s plot function, e.g. the style of the plotted points ‘or’
  • ms_limits (bool) – if set to True, automatically set axes boundaries to the sensorimotor boundaries (default: True)
plot_learning_curve(ax, squared_errors=False)[source]
density_plot(ax, topic_dims, t=None, res_x=40, res_y=40, width_x=4, width_y=4)[source]