aepsych.config¶
aepsych.config module¶
- class aepsych.config.Config(config_dict=None, config_fnames=None, config_str=None)[source]¶
Bases:
ConfigParser
Initialize the AEPsych config object. This can be used to instantiate most objects in AEPsych by calling object.from_config(config).
- Parameters:
config_dict (Mapping[str, str], optional) – Mapping to build configuration from. Keys are section names, values are dictionaries with keys and values that should be present in the section. Defaults to None.
config_fnames (Sequence[str], optional) – List of INI filenames to load configuration from. Defaults to None.
config_str (str, optional) – String formatted as an INI file to load configuration from. Defaults to None.
- registered_names: ClassVar[Dict[str, object]] = {'AEPsychObjective': <class 'aepsych.acquisition.objective.objective.AEPsychObjective'>, 'AcqfGridSearchGenerator': <class 'aepsych.generators.acqf_grid_search_generator.AcqfGridSearchGenerator'>, 'AcqfThompsonSamplerGenerator': <class 'aepsych.generators.acqf_thompson_sampler_generator.AcqfThompsonSamplerGenerator'>, 'AdditiveKernel': <class 'gpytorch.kernels.kernel.AdditiveKernel'>, 'AdditiveStructureKernel': <class 'gpytorch.kernels.additive_structure_kernel.AdditiveStructureKernel'>, 'ApproxGlobalSUR': <class 'aepsych.acquisition.lookahead.ApproxGlobalSUR'>, 'ArcKernel': <class 'gpytorch.kernels.arc_kernel.ArcKernel'>, 'BernoulliLikelihood': <class 'gpytorch.likelihoods.bernoulli_likelihood.BernoulliLikelihood'>, 'BernoulliMCMutualInformation': <class 'aepsych.acquisition.mutual_information.BernoulliMCMutualInformation'>, 'BernoulliObjectiveLikelihood': <class 'aepsych.likelihoods.bernoulli.BernoulliObjectiveLikelihood'>, 'BetaLikelihood': <class 'gpytorch.likelihoods.beta_likelihood.BetaLikelihood'>, 'ConstantKernel': <class 'gpytorch.kernels.constant_kernel.ConstantKernel'>, 'CosineKernel': <class 'gpytorch.kernels.cosine_kernel.CosineKernel'>, 'CylindricalKernel': <class 'gpytorch.kernels.cylindrical_kernel.CylindricalKernel'>, 'DirichletClassificationLikelihood': <class 'gpytorch.likelihoods.gaussian_likelihood.DirichletClassificationLikelihood'>, 'DistributionalInputKernel': <class 'gpytorch.kernels.distributional_input_kernel.DistributionalInputKernel'>, 'EAVC': <class 'aepsych.acquisition.lookahead.EAVC'>, 'EpsilonGreedyGenerator': <class 'aepsych.generators.epsilon_greedy_generator.EpsilonGreedyGenerator'>, 'FixedAllocator': <class 'aepsych.models.inducing_points.fixed.FixedAllocator'>, 'FixedNoiseGaussianLikelihood': <class 'gpytorch.likelihoods.gaussian_likelihood.FixedNoiseGaussianLikelihood'>, 'FloorGumbelObjective': <class 'aepsych.acquisition.objective.objective.FloorGumbelObjective'>, 'FloorLogitObjective': <class 'aepsych.acquisition.objective.objective.FloorLogitObjective'>, 'FloorProbitObjective': <class 'aepsych.acquisition.objective.objective.FloorProbitObjective'>, 'GPBetaRegressionModel': <class 'aepsych.models.gp_classification.GPBetaRegressionModel'>, 'GPClassificationModel': <class 'aepsych.models.gp_classification.GPClassificationModel'>, 'GPRegressionModel': <class 'aepsych.models.gp_regression.GPRegressionModel'>, 'GaussianLikelihood': <class 'gpytorch.likelihoods.gaussian_likelihood.GaussianLikelihood'>, 'GaussianLikelihoodWithMissingObs': <class 'gpytorch.likelihoods.gaussian_likelihood.GaussianLikelihoodWithMissingObs'>, 'GaussianSymmetrizedKLKernel': <class 'gpytorch.kernels.gaussian_symmetrized_kl_kernel.GaussianSymmetrizedKLKernel'>, 'GlobalMI': <class 'aepsych.acquisition.lookahead.GlobalMI'>, 'GlobalSUR': <class 'aepsych.acquisition.lookahead.GlobalSUR'>, 'GreedyVarianceReduction': <class 'aepsych.models.inducing_points.greedy_variance_reduction.GreedyVarianceReduction'>, 'GridInterpolationKernel': <class 'gpytorch.kernels.grid_interpolation_kernel.GridInterpolationKernel'>, 'GridKernel': <class 'gpytorch.kernels.grid_kernel.GridKernel'>, 'HadamardSemiPModel': <class 'aepsych.models.semi_p.HadamardSemiPModel'>, 'HammingIMQKernel': <class 'gpytorch.kernels.hamming_kernel.HammingIMQKernel'>, 'HeteroskedasticNoise': <class 'gpytorch.likelihoods.noise_models.HeteroskedasticNoise'>, 'IndexKernel': <class 'gpytorch.kernels.index_kernel.IndexKernel'>, 'InducingPointKernel': <class 'gpytorch.kernels.inducing_point_kernel.InducingPointKernel'>, 'IntensityAwareSemiPGenerator': <class 'aepsych.generators.semi_p.IntensityAwareSemiPGenerator'>, 'KMeansAllocator': <class 'aepsych.models.inducing_points.kmeans.KMeansAllocator'>, 'Kernel': <class 'gpytorch.kernels.kernel.Kernel'>, 'LCMKernel': <class 'gpytorch.kernels.lcm_kernel.LCMKernel'>, 'LaplaceLikelihood': <class 'gpytorch.likelihoods.laplace_likelihood.LaplaceLikelihood'>, 'Likelihood': <class 'gpytorch.likelihoods.likelihood.Likelihood'>, 'LikelihoodList': <class 'gpytorch.likelihoods.likelihood_list.LikelihoodList'>, 'LinearBernoulliLikelihood': <class 'aepsych.likelihoods.semi_p.LinearBernoulliLikelihood'>, 'LinearKernel': <class 'gpytorch.kernels.linear_kernel.LinearKernel'>, 'LocalMI': <class 'aepsych.acquisition.lookahead.LocalMI'>, 'LocalSUR': <class 'aepsych.acquisition.lookahead.LocalSUR'>, 'MCLevelSetEstimation': <class 'aepsych.acquisition.lse.MCLevelSetEstimation'>, 'MCPosteriorVariance': <class 'aepsych.acquisition.mc_posterior_variance.MCPosteriorVariance'>, 'ManualGenerator': <class 'aepsych.generators.manual_generator.ManualGenerator'>, 'Matern52KernelGrad': <class 'gpytorch.kernels.matern52_kernel_grad.Matern52KernelGrad'>, 'MaternKernel': <class 'gpytorch.kernels.matern_kernel.MaternKernel'>, 'MonotonicProjectionGP': <class 'aepsych.models.monotonic_projection_gp.MonotonicProjectionGP'>, 'MultiDeviceKernel': <class 'gpytorch.kernels.multi_device_kernel.MultiDeviceKernel'>, 'MultitaskGaussianLikelihood': <class 'gpytorch.likelihoods.multitask_gaussian_likelihood.MultitaskGaussianLikelihood'>, 'MultitaskKernel': <class 'gpytorch.kernels.multitask_kernel.MultitaskKernel'>, 'NewtonGirardAdditiveKernel': <class 'gpytorch.kernels.newton_girard_additive_kernel.NewtonGirardAdditiveKernel'>, 'None': None, 'OptimizeAcqfGenerator': <class 'aepsych.generators.optimize_acqf_generator.OptimizeAcqfGenerator'>, 'OrdinalGPModel': <class 'aepsych.models.ordinal_gp.OrdinalGPModel'>, 'OrdinalLikelihood': <class 'aepsych.likelihoods.ordinal.OrdinalLikelihood'>, 'PairwiseProbitModel': <class 'aepsych.models.pairwise_probit.PairwiseProbitModel'>, 'PeriodicKernel': <class 'gpytorch.kernels.periodic_kernel.PeriodicKernel'>, 'PiecewisePolynomialKernel': <class 'gpytorch.kernels.piecewise_polynomial_kernel.PiecewisePolynomialKernel'>, 'PolynomialKernel': <class 'gpytorch.kernels.polynomial_kernel.PolynomialKernel'>, 'PolynomialKernelGrad': <class 'gpytorch.kernels.polynomial_kernel_grad.PolynomialKernelGrad'>, 'ProbitObjective': <class 'aepsych.acquisition.objective.objective.ProbitObjective'>, 'ProductKernel': <class 'gpytorch.kernels.kernel.ProductKernel'>, 'ProductStructureKernel': <class 'gpytorch.kernels.product_structure_kernel.ProductStructureKernel'>, 'RBFKernel': <class 'gpytorch.kernels.rbf_kernel.RBFKernel'>, 'RBFKernelGrad': <class 'gpytorch.kernels.rbf_kernel_grad.RBFKernelGrad'>, 'RBFKernelGradGrad': <class 'gpytorch.kernels.rbf_kernel_gradgrad.RBFKernelGradGrad'>, 'RFFKernel': <class 'gpytorch.kernels.rff_kernel.RFFKernel'>, 'RQKernel': <class 'gpytorch.kernels.rq_kernel.RQKernel'>, 'RandomGenerator': <class 'aepsych.generators.random_generator.RandomGenerator'>, 'SampleAroundPointsGenerator': <class 'aepsych.generators.manual_generator.SampleAroundPointsGenerator'>, 'ScaleKernel': <class 'gpytorch.kernels.scale_kernel.ScaleKernel'>, 'SemiPProbabilityObjective': <class 'aepsych.acquisition.objective.semi_p.SemiPProbabilityObjective'>, 'SemiPThresholdObjective': <class 'aepsych.acquisition.objective.semi_p.SemiPThresholdObjective'>, 'SemiParametricGPModel': <class 'aepsych.models.semi_p.SemiParametricGPModel'>, 'SequentialStrategy': <class 'aepsych.strategy.sequential.SequentialStrategy'>, 'SobolAllocator': <class 'aepsych.models.inducing_points.sobol.SobolAllocator'>, 'SobolGenerator': <class 'aepsych.generators.sobol_generator.SobolGenerator'>, 'SoftmaxLikelihood': <class 'gpytorch.likelihoods.softmax_likelihood.SoftmaxLikelihood'>, 'SpectralDeltaKernel': <class 'gpytorch.kernels.spectral_delta_kernel.SpectralDeltaKernel'>, 'SpectralMixtureKernel': <class 'gpytorch.kernels.spectral_mixture_kernel.SpectralMixtureKernel'>, 'Strategy': <class 'aepsych.strategy.strategy.Strategy'>, 'StudentTLikelihood': <class 'gpytorch.likelihoods.student_t_likelihood.StudentTLikelihood'>, '_GaussianLikelihoodBase': <class 'gpytorch.likelihoods.gaussian_likelihood._GaussianLikelihoodBase'>, '_MultitaskGaussianLikelihoodBase': <class 'gpytorch.likelihoods.multitask_gaussian_likelihood._MultitaskGaussianLikelihoodBase'>, '_OneDimensionalLikelihood': <class 'gpytorch.likelihoods.likelihood._OneDimensionalLikelihood'>, 'default_mean_covar_factory': <function default_mean_covar_factory>, 'ordinal_mean_covar_factory': <function ordinal_mean_covar_factory>, 'pairwise_mean_covar_factory': <function pairwise_mean_covar_factory>, 'semi_p_posterior_transform': <function semi_p_posterior_transform>, 'song_mean_covar_factory': <function song_mean_covar_factory>}¶
- to_dict(deduplicate=True)[source]¶
Convert the config into a dictionary.
- Parameters:
deduplicate (bool) – Whether to deduplicate the ‘common’ section. Defaults to True.
- Returns:
Dictionary representation of the config.
- Return type:
dict
- get_metadata(only_extra=False)[source]¶
Return a dictionary of the metadata section.
- Parameters:
only_extra (bool, optional) – Only gather the extra metadata. Defaults to False.
- Returns:
a collection of the metadata stored in this conig.
- Return type:
Dict[Any, Any]
- jsonifyMetadata(only_extra=False)[source]¶
Return a json string of the metadata section.
- Parameters:
only_extra (bool) – Only jsonify the extra meta data.
- Returns:
- A json string representing the metadata dictionary or an empty string
if there is no metadata to return.
- Return type:
str
- jsonifyAll()[source]¶
Turn the entire config into JSON format.
- Returns:
JSON representation of the entire config.
- Return type:
str
- update(config_dict=None, config_fnames=None, config_str=None)[source]¶
Update this object with a new configuration.
- Parameters:
config_dict (Mapping[str, str], optional) – Mapping to build configuration from. Keys are section names, values are dictionaries with keys and values that should be present in the section. Defaults to None.
config_fnames (Sequence[str]) – List of INI filenames to load configuration from. Defaults to None.
config_str (str) – String formatted as an INI file to load configuration from. Defaults to None.
- Return type:
None
- classmethod register_module(module)[source]¶
- Register a module with Config so that objects in it can
be referred to by their string name in config files.
- Parameters:
module (ModuleType) – Module to register.
- Return type:
None
- class aepsych.config.ConfigurableMixin[source]¶
Bases:
ABC
- classmethod get_config_options(config, name=None, options=None)[source]¶
Return a dictionary of the relevant options to initialize this class from the config, even if it is outside of the named section. By default, this will look for options in name based on the __init__’s arguments/defaults.
- Parameters:
config (Config) – Config to look for options in.
name (str, optional) – Primary section to look for options for this class and the name to infer options from other sections in the config.
options (Dict[str, Any], optional) – Options to override from the config, defaults to None.
- Returns:
A dictionary of options to initialize this class.
- Return type:
Dict[str, Any]
- classmethod from_config(config, name=None, options=None)[source]¶
Return a initialized instance of this class using the config and the name.
- Parameters:
config (Config) – Config to use to initialize this class.
name (str, optional) – Name of section to look in first for this class.
options (Dict[str, Any], optional) – Options to override from the config, defaults to None.
- Returns:
Initialized class based on config and name.
- Return type: