aepsych.generators¶
Submodules¶
aepsych.generators.base module¶
- class aepsych.generators.base.AEPsychGenerator[source]¶
Bases:
ABC
,Generic
[AEPsychModelType
]Abstract base class for generators, which are responsible for generating new points to sample.
- stimuli_per_trial = 1¶
- max_asks: Optional[int] = None¶
- dim: int¶
- class aepsych.generators.base.AcqfGenerator(acqf, acqf_kwargs=None)[source]¶
Bases:
AEPsychGenerator
,ConfigurableMixin
Base class for generators that evaluate acquisition functions.
- Parameters:
acqf (botorch.acquisition.AcquisitionFunction) –
acqf_kwargs (Dict[str, Any]) –
- baseline_requiring_acqfs = [botorch.acquisition.qNoisyExpectedImprovement, botorch.acquisition.NoisyExpectedImprovement, botorch.acquisition.qLogNoisyExpectedImprovement, botorch.acquisition.LogNoisyExpectedImprovement]¶
- acqf: botorch.acquisition.AcquisitionFunction¶
- acqf_kwargs: Dict[str, Any]¶
- classmethod get_config_options(config, name=None, options=None)[source]¶
Get configuration options for the generator.
- Parameters:
config (Config) – Configuration object.
name (str, optional) – Name of the generator, defaults to None. Ignored.
options (Dict[str, Any], optional) – Additional options, defaults to None.
- Returns:
Configuration options for the generator.
- Return type:
Dict[str, Any]
aepsych.generators.epsilon_greedy_generator module¶
- class aepsych.generators.epsilon_greedy_generator.EpsilonGreedyGenerator(lb, ub, subgenerator, epsilon=0.1)[source]¶
Bases:
AEPsychGenerator
Initialize EpsilonGreedyGenerator.
- Parameters:
lb (torch.Tensor) – Lower bounds for the optimization.
ub (torch.Tensor) – Upper bounds for the optimization.
subgenerator (AEPsychGenerator) – The generator to use when not exploiting.
epsilon (float) – The probability of exploration. Defaults to 0.1.
- classmethod from_config(config)[source]¶
Create an EpsilonGreedyGenerator from a Config object.
- Parameters:
config (Config) – Configuration object containing initialization parameters.
- Returns:
The generator.
- Return type:
- gen(num_points, model, fixed_features=None, **kwargs)[source]¶
Query next point(s) to run by sampling from the subgenerator with probability 1-epsilon, and randomly otherwise.
- Parameters:
num_points (int) – Number of points to query.
model (ModelProtocol) – Model to use for generating points.
fixed_features (Optional[Dict[int, float]]) – (Dict[int, float], optional): Parameters that are fixed to specific values.
**kwargs – Passed to subgenerator if not exploring
- Return type:
Tensor
aepsych.generators.manual_generator module¶
- class aepsych.generators.manual_generator.ManualGenerator(lb, ub, points, dim=None, shuffle=True, seed=None)[source]¶
Bases:
AEPsychGenerator
Generator that generates points from a predefined list.
Iniatialize ManualGenerator. :param lb: Lower bounds of each parameter. :type lb: torch.Tensor :param ub: Upper bounds of each parameter. :type ub: torch.Tensor :param points: The points that will be generated. :type points: torch.Tensor :param dim: Dimensionality of the parameter space. If None, it is inferred from lb and ub. :type dim: int, optional :param shuffle: Whether or not to shuffle the order of the points. True by default. :type shuffle: bool :param seed: Random seed. Defaults to None. :type seed: int, optional
- Parameters:
lb (Tensor) –
ub (Tensor) –
points (Tensor) –
dim (int) –
shuffle (bool) –
seed (Optional[int]) –
- gen(num_points=1, model=None, fixed_features=None, **kwargs)[source]¶
Query next point(s) to run by quasi-randomly sampling the parameter space. :param num_points: Number of points to query. Defaults to 1. :type num_points: int :param model: Model to use for generating points. Not used in this generator. Defaults to None. :type model: AEPsychMixin, optional :param fixed_features: Ignored, kept for consistent
API.
- Parameters:
**kwargs – Ignored, API compatibility
num_points (int) –
model (Optional[AEPsychMixin]) –
fixed_features (Dict[int, float], optional) –
- Returns:
Next set of point(s) to evaluate, [num_points x dim].
- Return type:
torch.Tensor
- classmethod from_config(config, name=None)[source]¶
- Parameters:
config (Config) –
name (Optional[str]) –
- Return type:
- classmethod get_config_options(config, name=None)[source]¶
Extracts and processes configuration options for initializing the ManualGenerator.
- Parameters:
config (Config) – Configuration object containing initialization parameters.
name (str, optional) – Name of the configuration section for this generator. Defaults to the class name.
- Returns:
- A dictionary of options, including:
”lb” (torch.Tensor): Lower bounds of each parameter. “ub” (torch.Tensor): Upper bounds of each parameter. “dim” (int, optional): Dimensionality of the parameter space. “points” (torch.Tensor): Predefined points to generate. “shuffle” (bool): Whether to shuffle the order of points. “seed” (int, optional): Random seed for shuffling.
- Return type:
Dict
- property finished: bool¶
- class aepsych.generators.manual_generator.SampleAroundPointsGenerator(lb, ub, window, points, samples_per_point, dim=None, shuffle=True, seed=None)[source]¶
Bases:
ManualGenerator
Generator that samples in a window around reference points in a predefined list.
Iniatialize SampleAroundPointsGenerator. :param lb: Lower bounds of each parameter. :type lb: torch.Tensor :param ub: Upper bounds of each parameter. :type ub: torch.Tensor :param window: How far away to sample from the reference point along each dimension. :type window: torch.Tensor :param points: The points that will be generated. :type points: torch.Tensor :param samples_per_point: How many samples around each point to take. :type samples_per_point: int :param dim: Dimensionality of the parameter space. If None, it is inferred from lb and ub. :type dim: int, optional :param shuffle: Whether or not to shuffle the order of the points. True by default. :type shuffle: bool :param seed: Random seed. :type seed: int, optional
- Parameters:
lb (Tensor) –
ub (Tensor) –
window (Tensor) –
points (Tensor) –
samples_per_point (int) –
dim (int) –
shuffle (bool) –
seed (Optional[int]) –
- classmethod get_config_options(config, name=None)[source]¶
Extracts and processes configuration options for initializing the SampleAroundPointsGenerator.
- Parameters:
config (Config) – Configuration object containing initialization parameters.
name (str, optional) – Name of the configuration section for this generator. Defaults to the class name.
- Returns:
- A dictionary of options, including:
”lb” (torch.Tensor): Lower bounds of each parameter.
”ub” (torch.Tensor): Upper bounds of each parameter.
”dim” (int, optional): Dimensionality of the parameter space.
”points” (torch.Tensor): Predefined reference points.
”shuffle” (bool): Whether to shuffle the order of points.
”seed” (int, optional): Random seed for shuffling.
”window” (torch.Tensor): Sampling range around each reference point along each dimension.
”samples_per_point” (int): Number of samples to generate around each reference point.
- Return type:
Dict
aepsych.generators.monotonic_rejection_generator module¶
aepsych.generators.monotonic_thompson_sampler_generator module¶
aepsych.generators.optimize_acqf_generator module¶
- class aepsych.generators.optimize_acqf_generator.OptimizeAcqfGenerator(lb, ub, acqf, acqf_kwargs=None, restarts=10, samps=1024, max_gen_time=None, stimuli_per_trial=1)[source]¶
Bases:
AcqfGenerator
Generator that chooses points by minimizing an acquisition function.
Initialize OptimizeAcqfGenerator. :param lb: Lower bounds for the optimization. :type lb: torch.Tensor :param ub: Upper bounds for the optimization. :type ub: torch.Tensor :param acqf: Acquisition function to use. :type acqf: AcquisitionFunction :param acqf_kwargs: Extra arguments to
pass to acquisition function. Defaults to no arguments.
- Parameters:
restarts (int) – Number of restarts for acquisition function optimization. Defaults to 10.
samps (int) – Number of samples for quasi-random initialization of the acquisition function optimizer. Defaults to 1000.
max_gen_time (float, optional) – Maximum time (in seconds) to optimize the acquisition function. Defaults to None.
stimuli_per_trial (int) – Number of stimuli per trial. Defaults to 1.
lb (torch.Tensor) –
ub (torch.Tensor) –
acqf (botorch.acquisition.AcquisitionFunction) –
acqf_kwargs (Dict[str, object], optional) –
- gen(num_points, model, fixed_features=None, **gen_options)[source]¶
Query next point(s) to run by optimizing the acquisition function. :param num_points: Number of points to query. :type num_points: int :param model: Fitted model of the data. :type model: ModelProtocol :param fixed_features: The values where the specified
parameters should be at when generating. Should be a dictionary where the keys are the indices of the parameters to fix and the values are the values to fix them at.
- Parameters:
**gen_options – Additional options for generating points, such as custom configurations.
num_points (int) –
model (ModelProtocol) –
fixed_features (Dict[int, float], optional) –
- Returns:
Next set of point(s) to evaluate, [num_points x dim].
- Return type:
torch.Tensor
- classmethod get_config_options(config, name=None, options=None)[source]¶
Get configuration options for the generator.
- Parameters:
config (Config) – Configuration object.
name (str, optional) – Name of the generator, defaults to None.
options (Dict[str, Any], optional) – Additional options, defaults to None.
- Returns:
Configuration options for the generator.
- Return type:
Dict[str, Any]
aepsych.generators.random_generator module¶
- class aepsych.generators.random_generator.RandomGenerator(lb, ub, dim=None)[source]¶
Bases:
AEPsychGenerator
Generator that generates points randomly without an acquisition function.
Iniatialize RandomGenerator. :param lb: Lower bounds of each parameter. :type lb: torch.Tensor :param ub: Upper bounds of each parameter. :type ub: torch.Tensor :param dim: Dimensionality of the parameter space. If None, it is inferred from lb and ub. :type dim: int, optional
- Parameters:
lb (Tensor) –
ub (Tensor) –
dim (int) –
- gen(num_points=1, model=None, fixed_features=None, **kwargs)[source]¶
Query next point(s) to run by randomly sampling the parameter space. :param num_points: Number of points to query. Currently, only 1 point can be queried at a time. :type num_points: int :param model: Model to use for generating points. Not used in this generator. :type model: AEPsychMixin, optional :param fixed_features: (Dict[int, float], optional): Parameters that are fixed to specific values. :param **kwargs: Ignored, API compatibility
- Returns:
Next set of point(s) to evaluate, [num_points x dim].
- Return type:
torch.Tensor
- Parameters:
num_points (int) –
model (Optional[AEPsychMixin]) –
fixed_features (Optional[Dict[int, float]]) –
aepsych.generators.sobol_generator module¶
- class aepsych.generators.sobol_generator.SobolGenerator(lb, ub, dim=None, seed=None, stimuli_per_trial=1)[source]¶
Bases:
AEPsychGenerator
Generator that generates points from the Sobol Sequence.
Iniatialize SobolGenerator. :param lb: Lower bounds of each parameter. :type lb: torch.Tensor :param ub: Upper bounds of each parameter. :type ub: torch.Tensor :param dim: Dimensionality of the parameter space. If None, it is inferred from lb and ub. :type dim: int, optional :param seed: Random seed. :type seed: int, optional :param stimuli_per_trial: Number of stimuli per trial. Defaults to 1. :type stimuli_per_trial: int
- Parameters:
lb (torch.Tensor) –
ub (torch.Tensor) –
dim (int) –
seed (Optional[int]) –
stimuli_per_trial (int) –
- gen(num_points=1, model=None, fixed_features=None, **kwargs)[source]¶
Query next point(s) to run by quasi-randomly sampling the parameter space. :param num_points: Number of points to query. Defaults to 1. :type num_points: int :param moodel: Model to use for generating points. Not used in this generator. Defaults to None. :type moodel: AEPsychMixin, optional :param fixed_features: (Dict[int, float], optional): Parameters that are fixed to specific values. :param **kwargs: Ignored, API compatibility
- Returns:
Next set of point(s) to evaluate, [num_points x dim] or [num_points x dim x stimuli_per_trial] if stimuli_per_trial != 1.
- Return type:
torch.Tensor
- Parameters:
num_points (int) –
model (Optional[AEPsychMixin]) –
fixed_features (Optional[Dict[int, float]]) –
- classmethod from_config(config)[source]¶
Creates an instance of SobolGenerator from a configuration object.
- Parameters:
config (Config) – Configuration object containing initialization parameters.
- Returns:
A configured instance of the generator with specified bounds, dimensionality, random seed, and stimuli per trial.
- Return type:
Module contents¶
- class aepsych.generators.OptimizeAcqfGenerator(lb, ub, acqf, acqf_kwargs=None, restarts=10, samps=1024, max_gen_time=None, stimuli_per_trial=1)[source]¶
Bases:
AcqfGenerator
Generator that chooses points by minimizing an acquisition function.
Initialize OptimizeAcqfGenerator. :param lb: Lower bounds for the optimization. :type lb: torch.Tensor :param ub: Upper bounds for the optimization. :type ub: torch.Tensor :param acqf: Acquisition function to use. :type acqf: AcquisitionFunction :param acqf_kwargs: Extra arguments to
pass to acquisition function. Defaults to no arguments.
- Parameters:
restarts (int) – Number of restarts for acquisition function optimization. Defaults to 10.
samps (int) – Number of samples for quasi-random initialization of the acquisition function optimizer. Defaults to 1000.
max_gen_time (float, optional) – Maximum time (in seconds) to optimize the acquisition function. Defaults to None.
stimuli_per_trial (int) – Number of stimuli per trial. Defaults to 1.
lb (torch.Tensor) –
ub (torch.Tensor) –
acqf (botorch.acquisition.AcquisitionFunction) –
acqf_kwargs (Dict[str, object], optional) –
- gen(num_points, model, fixed_features=None, **gen_options)[source]¶
Query next point(s) to run by optimizing the acquisition function. :param num_points: Number of points to query. :type num_points: int :param model: Fitted model of the data. :type model: ModelProtocol :param fixed_features: The values where the specified
parameters should be at when generating. Should be a dictionary where the keys are the indices of the parameters to fix and the values are the values to fix them at.
- Parameters:
**gen_options – Additional options for generating points, such as custom configurations.
num_points (int) –
model (ModelProtocol) –
fixed_features (Dict[int, float], optional) –
- Returns:
Next set of point(s) to evaluate, [num_points x dim].
- Return type:
torch.Tensor
- classmethod get_config_options(config, name=None, options=None)[source]¶
Get configuration options for the generator.
- Parameters:
config (Config) – Configuration object.
name (str, optional) – Name of the generator, defaults to None.
options (Dict[str, Any], optional) – Additional options, defaults to None.
- Returns:
Configuration options for the generator.
- Return type:
Dict[str, Any]
- class aepsych.generators.RandomGenerator(lb, ub, dim=None)[source]¶
Bases:
AEPsychGenerator
Generator that generates points randomly without an acquisition function.
Iniatialize RandomGenerator. :param lb: Lower bounds of each parameter. :type lb: torch.Tensor :param ub: Upper bounds of each parameter. :type ub: torch.Tensor :param dim: Dimensionality of the parameter space. If None, it is inferred from lb and ub. :type dim: int, optional
- Parameters:
lb (Tensor) –
ub (Tensor) –
dim (int) –
- gen(num_points=1, model=None, fixed_features=None, **kwargs)[source]¶
Query next point(s) to run by randomly sampling the parameter space. :param num_points: Number of points to query. Currently, only 1 point can be queried at a time. :type num_points: int :param model: Model to use for generating points. Not used in this generator. :type model: AEPsychMixin, optional :param fixed_features: (Dict[int, float], optional): Parameters that are fixed to specific values. :param **kwargs: Ignored, API compatibility
- Returns:
Next set of point(s) to evaluate, [num_points x dim].
- Return type:
torch.Tensor
- Parameters:
num_points (int) –
model (Optional[AEPsychMixin]) –
fixed_features (Optional[Dict[int, float]]) –
- class aepsych.generators.SobolGenerator(lb, ub, dim=None, seed=None, stimuli_per_trial=1)[source]¶
Bases:
AEPsychGenerator
Generator that generates points from the Sobol Sequence.
Iniatialize SobolGenerator. :param lb: Lower bounds of each parameter. :type lb: torch.Tensor :param ub: Upper bounds of each parameter. :type ub: torch.Tensor :param dim: Dimensionality of the parameter space. If None, it is inferred from lb and ub. :type dim: int, optional :param seed: Random seed. :type seed: int, optional :param stimuli_per_trial: Number of stimuli per trial. Defaults to 1. :type stimuli_per_trial: int
- Parameters:
lb (torch.Tensor) –
ub (torch.Tensor) –
dim (int) –
seed (Optional[int]) –
stimuli_per_trial (int) –
- gen(num_points=1, model=None, fixed_features=None, **kwargs)[source]¶
Query next point(s) to run by quasi-randomly sampling the parameter space. :param num_points: Number of points to query. Defaults to 1. :type num_points: int :param moodel: Model to use for generating points. Not used in this generator. Defaults to None. :type moodel: AEPsychMixin, optional :param fixed_features: (Dict[int, float], optional): Parameters that are fixed to specific values. :param **kwargs: Ignored, API compatibility
- Returns:
Next set of point(s) to evaluate, [num_points x dim] or [num_points x dim x stimuli_per_trial] if stimuli_per_trial != 1.
- Return type:
torch.Tensor
- Parameters:
num_points (int) –
model (Optional[AEPsychMixin]) –
fixed_features (Optional[Dict[int, float]]) –
- classmethod from_config(config)[source]¶
Creates an instance of SobolGenerator from a configuration object.
- Parameters:
config (Config) – Configuration object containing initialization parameters.
- Returns:
A configured instance of the generator with specified bounds, dimensionality, random seed, and stimuli per trial.
- Return type:
- class aepsych.generators.EpsilonGreedyGenerator(lb, ub, subgenerator, epsilon=0.1)[source]¶
Bases:
AEPsychGenerator
Initialize EpsilonGreedyGenerator.
- Parameters:
lb (torch.Tensor) – Lower bounds for the optimization.
ub (torch.Tensor) – Upper bounds for the optimization.
subgenerator (AEPsychGenerator) – The generator to use when not exploiting.
epsilon (float) – The probability of exploration. Defaults to 0.1.
- classmethod from_config(config)[source]¶
Create an EpsilonGreedyGenerator from a Config object.
- Parameters:
config (Config) – Configuration object containing initialization parameters.
- Returns:
The generator.
- Return type:
- gen(num_points, model, fixed_features=None, **kwargs)[source]¶
Query next point(s) to run by sampling from the subgenerator with probability 1-epsilon, and randomly otherwise.
- Parameters:
num_points (int) – Number of points to query.
model (ModelProtocol) – Model to use for generating points.
fixed_features (Optional[Dict[int, float]]) – (Dict[int, float], optional): Parameters that are fixed to specific values.
**kwargs – Passed to subgenerator if not exploring
- Return type:
Tensor
- class aepsych.generators.ManualGenerator(lb, ub, points, dim=None, shuffle=True, seed=None)[source]¶
Bases:
AEPsychGenerator
Generator that generates points from a predefined list.
Iniatialize ManualGenerator. :param lb: Lower bounds of each parameter. :type lb: torch.Tensor :param ub: Upper bounds of each parameter. :type ub: torch.Tensor :param points: The points that will be generated. :type points: torch.Tensor :param dim: Dimensionality of the parameter space. If None, it is inferred from lb and ub. :type dim: int, optional :param shuffle: Whether or not to shuffle the order of the points. True by default. :type shuffle: bool :param seed: Random seed. Defaults to None. :type seed: int, optional
- Parameters:
lb (Tensor) –
ub (Tensor) –
points (Tensor) –
dim (int) –
shuffle (bool) –
seed (Optional[int]) –
- gen(num_points=1, model=None, fixed_features=None, **kwargs)[source]¶
Query next point(s) to run by quasi-randomly sampling the parameter space. :param num_points: Number of points to query. Defaults to 1. :type num_points: int :param model: Model to use for generating points. Not used in this generator. Defaults to None. :type model: AEPsychMixin, optional :param fixed_features: Ignored, kept for consistent
API.
- Parameters:
**kwargs – Ignored, API compatibility
num_points (int) –
model (Optional[AEPsychMixin]) –
fixed_features (Dict[int, float], optional) –
- Returns:
Next set of point(s) to evaluate, [num_points x dim].
- Return type:
torch.Tensor
- classmethod from_config(config, name=None)[source]¶
- Parameters:
config (Config) –
name (Optional[str]) –
- Return type:
- classmethod get_config_options(config, name=None)[source]¶
Extracts and processes configuration options for initializing the ManualGenerator.
- Parameters:
config (Config) – Configuration object containing initialization parameters.
name (str, optional) – Name of the configuration section for this generator. Defaults to the class name.
- Returns:
- A dictionary of options, including:
”lb” (torch.Tensor): Lower bounds of each parameter. “ub” (torch.Tensor): Upper bounds of each parameter. “dim” (int, optional): Dimensionality of the parameter space. “points” (torch.Tensor): Predefined points to generate. “shuffle” (bool): Whether to shuffle the order of points. “seed” (int, optional): Random seed for shuffling.
- Return type:
Dict
- property finished: bool¶
- class aepsych.generators.SampleAroundPointsGenerator(lb, ub, window, points, samples_per_point, dim=None, shuffle=True, seed=None)[source]¶
Bases:
ManualGenerator
Generator that samples in a window around reference points in a predefined list.
Iniatialize SampleAroundPointsGenerator. :param lb: Lower bounds of each parameter. :type lb: torch.Tensor :param ub: Upper bounds of each parameter. :type ub: torch.Tensor :param window: How far away to sample from the reference point along each dimension. :type window: torch.Tensor :param points: The points that will be generated. :type points: torch.Tensor :param samples_per_point: How many samples around each point to take. :type samples_per_point: int :param dim: Dimensionality of the parameter space. If None, it is inferred from lb and ub. :type dim: int, optional :param shuffle: Whether or not to shuffle the order of the points. True by default. :type shuffle: bool :param seed: Random seed. :type seed: int, optional
- Parameters:
lb (Tensor) –
ub (Tensor) –
window (Tensor) –
points (Tensor) –
samples_per_point (int) –
dim (int) –
shuffle (bool) –
seed (Optional[int]) –
- classmethod get_config_options(config, name=None)[source]¶
Extracts and processes configuration options for initializing the SampleAroundPointsGenerator.
- Parameters:
config (Config) – Configuration object containing initialization parameters.
name (str, optional) – Name of the configuration section for this generator. Defaults to the class name.
- Returns:
- A dictionary of options, including:
”lb” (torch.Tensor): Lower bounds of each parameter.
”ub” (torch.Tensor): Upper bounds of each parameter.
”dim” (int, optional): Dimensionality of the parameter space.
”points” (torch.Tensor): Predefined reference points.
”shuffle” (bool): Whether to shuffle the order of points.
”seed” (int, optional): Random seed for shuffling.
”window” (torch.Tensor): Sampling range around each reference point along each dimension.
”samples_per_point” (int): Number of samples to generate around each reference point.
- Return type:
Dict
- class aepsych.generators.IntensityAwareSemiPGenerator(lb, ub, acqf, acqf_kwargs=None, restarts=10, samps=1024, max_gen_time=None, stimuli_per_trial=1)[source]¶
Bases:
OptimizeAcqfGenerator
Generator for SemiP. With botorch machinery, in order to optimize acquisition separately over context and intensity, we need two ingredients. 1. An objective that samples from some posterior w.r.t. the context. From the
paper, this is ThresholdBALV and needs the threshold posterior. SemiPThresholdObjective implements this for ThresholdBALV but theoretically this can be any subclass of SemiPObjectiveBase.
- A way to do acquisition over context and intensity separately, which is
provided by this class. We optimize the acquisition function over context dimensions, then conditioned on the optimum we evaluate the intensity at the objective to obtain the intensity value.
We only developed ThresholdBALV that is specific to SemiP, which is what we tested with this generator. It should work with other similar acquisition functions.
Initialize OptimizeAcqfGenerator. :param lb: Lower bounds for the optimization. :type lb: torch.Tensor :param ub: Upper bounds for the optimization. :type ub: torch.Tensor :param acqf: Acquisition function to use. :type acqf: AcquisitionFunction :param acqf_kwargs: Extra arguments to
pass to acquisition function. Defaults to no arguments.
- Parameters:
restarts (int) – Number of restarts for acquisition function optimization. Defaults to 10.
samps (int) – Number of samples for quasi-random initialization of the acquisition function optimizer. Defaults to 1000.
max_gen_time (float, optional) – Maximum time (in seconds) to optimize the acquisition function. Defaults to None.
stimuli_per_trial (int) – Number of stimuli per trial. Defaults to 1.
lb (torch.Tensor) –
ub (torch.Tensor) –
acqf (botorch.acquisition.AcquisitionFunction) –
acqf_kwargs (Dict[str, object], optional) –
- gen(num_points, model, context_objective=<class 'aepsych.acquisition.objective.semi_p.SemiPThresholdObjective'>, fixed_features=None, **kwargs)[source]¶
Query next point(s) to run by optimizing the acquisition function for both context and intensity.
- Parameters:
num_points (int) – Number of points to query.
model (SemiParametricGPModel) – Fitted semi-parametric model of the data.
context_objective (Type) – The objective function used for context. Defaults to SemiPThresholdObjective.
fixed_features (Dict[int, float], optional) – Not implemented for this generator.
**kwargs – Passed to generator
- Returns:
Next set of point(s) to evaluate, [num_points x dim].
- Return type:
torch.Tensor
- class aepsych.generators.AcqfThompsonSamplerGenerator(lb, ub, acqf, acqf_kwargs=None, samps=1024, stimuli_per_trial=1, grid_generator=None)[source]¶
Bases:
GridEvalAcqfGenerator
Generator that samples points in a grid with probability proportional to an acquisition function value.
Initialize GridEvalAcqfGenerator. :param lb: Lower bounds for the optimization. :type lb: torch.Tensor :param ub: Upper bounds for the optimization. :type ub: torch.Tensor :param acqf: Acquisition function to use. :type acqf: AcquisitionFunction :param acqf_kwargs: Extra arguments to
pass to acquisition function. Defaults to no arguments.
- Parameters:
samps (int) – Number of quasi-random samples to evaluate acquisition function on. Defaults to 1000.
stimuli_per_trial (int) – Number of stimuli per trial. Defaults to 1.
lb (Tensor) –
ub (Tensor) –
acqf (botorch.acquisition.AcquisitionFunction) –
acqf_kwargs (Dict[str, object], optional) –
grid_generator (Optional[AEPsychGenerator]) –
- class aepsych.generators.AcqfGridSearchGenerator(lb, ub, acqf, acqf_kwargs=None, samps=1024, stimuli_per_trial=1, grid_generator=None)[source]¶
Bases:
GridEvalAcqfGenerator
Generator that samples points in a grid with probability proportional to an acquisition function value.
Initialize GridEvalAcqfGenerator. :param lb: Lower bounds for the optimization. :type lb: torch.Tensor :param ub: Upper bounds for the optimization. :type ub: torch.Tensor :param acqf: Acquisition function to use. :type acqf: AcquisitionFunction :param acqf_kwargs: Extra arguments to
pass to acquisition function. Defaults to no arguments.
- Parameters:
samps (int) – Number of quasi-random samples to evaluate acquisition function on. Defaults to 1000.
stimuli_per_trial (int) – Number of stimuli per trial. Defaults to 1.
lb (Tensor) –
ub (Tensor) –
acqf (botorch.acquisition.AcquisitionFunction) –
acqf_kwargs (Dict[str, object], optional) –
grid_generator (Optional[AEPsychGenerator]) –