Skip to content

Commit

Permalink
Merge pull request #4 from AutoResearch/3-make-consistent-with-synthe…
Browse files Browse the repository at this point in the history
…tic-v200

rename experiment_runner to run
  • Loading branch information
younesStrittmatter authored Dec 11, 2023
2 parents 6c0f0b0 + 3b53468 commit b9ebde7
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ def equation_experiment(
1 2 3
2 3 4
Then to run the experiment, we pass that dataframe to the `.experiment_runner` function:
>>> experiment.experiment_runner(conditions)
Then to run the experiment, we pass that dataframe to the `.run` function:
>>> experiment.run(conditions)
x y z
0 1 2 1.003047
1 2 3 7.989600
2 3 4 81.007505
If the names the expression requires are not part of the dataframe, we get an error message:
>>> experiment.experiment_runner(
>>> experiment.run(
... pd.DataFrame({'z':[1, 2, 2], 'x': [1, 2, 3]})
... ) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
Traceback (most recent call last):
Expand All @@ -81,27 +81,27 @@ def equation_experiment(
Each time an experiment is initialized with the same random_state, it should produce the
same results:
>>> experiment = equation_experiment(expr, [iv_x, iv_y], dv_z, random_state=42)
>>> results42 = experiment.experiment_runner(conditions)
>>> results42 = experiment.run(conditions)
>>> results42
x y z
0 1 2 1.003047
1 2 3 7.989600
2 3 4 81.007505
We can specify the random_state for a particular run to reproduce it:
>>> results42_reproduced = experiment.experiment_runner(conditions, random_state=42)
>>> results42_reproduced = experiment.run(conditions, random_state=42)
>>> pd.DataFrame.equals(results42, results42_reproduced)
True
If we don't specify the random_state, it produces different values:
>>> experiment.experiment_runner(conditions)
>>> experiment.run(conditions)
x y z
0 1 2 1.009406
1 2 3 7.980490
2 3 4 80.986978
An alternative input format for the experiment runner is a numpy array (not recommended):
>>> experiment.experiment_runner(np.array([[1, 1], [2, 2], [2, 3]]))
>>> experiment.run(np.array([[1, 1], [2, 2], [2, 3]]))
x y z
0 1 1 1.001278
1 2 2 3.996838
Expand All @@ -111,7 +111,7 @@ def equation_experiment(
will be sorted alphabetically.
In the following case the first entry of the numpy array is still x:
>>> expr = y ** x
>>> experiment.experiment_runner(np.array([[1, 1], [2, 2] , [2, 3]]), random_state=42)
>>> experiment.run(np.array([[1, 1], [2, 2] , [2, 3]]), random_state=42)
x y z
0 1 1 1.003047
1 2 2 3.989600
Expand Down Expand Up @@ -147,7 +147,7 @@ def equation_experiment(
# Define experiment runner
rng = np.random.default_rng(random_state)

def experiment_runner(
def run(
conditions: Union[pd.DataFrame, np.ndarray, np.recarray],
added_noise=0.01,
random_state=None,
Expand Down Expand Up @@ -195,7 +195,7 @@ def experiment_runner(
res[y.name] = out
return res

ground_truth = partial(experiment_runner, added_noise_=0.0)
ground_truth = partial(run, added_noise_=0.0)
"""A function which simulates perfect observations"""

def domain():
Expand Down Expand Up @@ -247,7 +247,7 @@ def plotter(model=None):
name=name,
description=equation_experiment.__doc__,
variables=variables,
experiment_runner=experiment_runner,
run=run,
ground_truth=ground_truth,
domain=domain,
plotter=plotter,
Expand Down

0 comments on commit b9ebde7

Please sign in to comment.