autora.variable
: Variable
and VariableCollection
¶
autora.variable.Variable
represents an experimental variable:
- an independent variable, or
- dependent variable.
They can be initialized as follows:
from autora.variable import Variable
x1 = Variable(
name="x1",
)
x2 = Variable(
name="x2",
)
y = Variable(
name="y",
)
A group of Variables
representing the domain of an experiment is a autora.variable.VariableCollection
.
They can be initialized as follows:
from autora.variable import VariableCollection
VariableCollection(
independent_variables=[x1, x2],
dependent_variables=[y]
)
VariableCollection(independent_variables=[Variable(name='x1', value_range=None, allowed_values=None, units='', type=<ValueType.REAL: 'real'>, variable_label='', rescale=1, is_covariate=False), Variable(name='x2', value_range=None, allowed_values=None, units='', type=<ValueType.REAL: 'real'>, variable_label='', rescale=1, is_covariate=False)], dependent_variables=[Variable(name='y', value_range=None, allowed_values=None, units='', type=<ValueType.REAL: 'real'>, variable_label='', rescale=1, is_covariate=False)], covariates=[])
For the full list of arguments, see the documentation in the autora.variable
submodule.
Some functions included in AutoRA use specific values stored on the Variable objects. For instance, the
autora.experimentalist.grid.pool
uses the allowed_values
field to create a grid of conditions:
from autora.experimentalist.grid import grid_pool
grid_pool(
VariableCollection(independent_variables=[
Variable(name="x1", allowed_values=[-1, -2, -3]),
Variable(name="x2", allowed_values=[11, 12, 13])
])
)
x1 | x2 | |
---|---|---|
0 | -1 | 11 |
1 | -1 | 12 |
2 | -1 | 13 |
3 | -2 | 11 |
4 | -2 | 12 |
5 | -2 | 13 |
6 | -3 | 11 |
7 | -3 | 12 |
8 | -3 | 13 |
The autora.experimentalist.random.pool
uses the value_range
field to sample conditions:
from autora.experimentalist.random import random_pool
random_pool(
VariableCollection(independent_variables=[
Variable(name="x1", value_range=(-3, 3)),
Variable(name="x2", value_range=(101, 102))
]),
random_state=180
)
x1 | x2 | |
---|---|---|
0 | 0.456338 | 101.527294 |
1 | 1.008636 | 101.297280 |
2 | 0.319617 | 101.962166 |
3 | -1.753273 | 101.859696 |
4 | -1.933420 | 101.201565 |
The autora.state.estimator_from_state
function uses the names
of the variables to pass the correct columns to a
scikit-learn
compatible estimator for curve fitting.
Check the documentation for any functions you are using to determine whether you need to include specific metadata.