piglot.optimisers.botorch package
Submodules
piglot.optimisers.botorch.bayes module
Main optimiser classes for using BoTorch with piglot
- class BayesianBoTorch(objective: Objective, n_initial: int | None = None, n_test: int = 0, acquisition: str | None = None, beta: float = 1.0, noisy: float = False, q: int = 1, seed: int = 1, load_file: str | None = None, export: str | None = None, device: str | None = None, reference_point: List[float] | None = None, nadir_scale: float = 0.1, skip_initial: bool = False, pca_variance: float | None = None, num_restarts: int | None = None, raw_samples: int | None = None, mc_samples: int | None = None, batch_size: int | None = None, num_fantasies: int | None = None, sequential: bool = False)[source]
Bases:
OptimiserDriver for optimisation using BoTorch.
- default_acquisition(composite: bool, multi_objective: bool, noisy: bool, q: int) str[source]
Return the default acquisition function for the given optimisation problem.
Parameters
- compositebool, optional
Whether the optimisation problem is a composition.
- multi_objectivebool, optional
Whether the optimisation problem is multi-objective.
- noisybool, optional
Whether the optimisation problem is noisy.
- qint, optional
Number of candidates to generate.
Returns
- str
Name of the default acquisition function.
piglot.optimisers.botorch.dataset module
Dataset classes for optimising with BoTorch.
- class BayesDataset(n_dim: int, n_outputs: int, export: str | None = None, dtype: dtype = torch.float64, std_tol: float = 1e-06, pca_variance: float | None = None, device: str = 'cpu')[source]
Bases:
objectDataset class for multi-outcome data.
- classmethod load(filename: str) T[source]
Load data from a given input file.
Parameters
- filenamestr
Path to the file to read from.
Returns
- BayesDataset
Dataset loaded from the file.
- min() Tuple[ndarray, ndarray][source]
Return the minimum objective value of the dataset.
Returns
- Tuple[np.ndarray, np.ndarray]
Parameters and objective value for the minimum point.
- numel_latent_space() int[source]
Return the number of components of the latent space.
Returns
- int
Number of components of the latent space.
- push(params: ndarray, results: ndarray, covariance: ndarray, objective: float | None) None[source]
Add a point to the dataset.
Parameters
- paramsnp.ndarray
Parameter values for this observation.
- resultObjectiveResult
Result for this observation.
- save(filename: str) None[source]
Save all dataset data to a file.
Parameters
- filenamestr
Output file path.
- to(device: str) BayesDataset[source]
Move the dataset to a given device.
Parameters
- devicestr
Device to move the dataset to.
Returns
- BayesDataset
The dataset in the new device.
- transform_outcomes(values: Tensor | None = None, covariances: Tensor | None = None, diagonalise: bool = True) Tuple[Tensor, Tensor][source]
Transform outcomes to the latent standardised space.
Parameters
- valuestorch.Tensor
Values to transform.
- covariancestorch.Tensor
Variances to transform.
- diagonalisebool
Whether to diagonalise the covariance matrix (default: True).
Returns
- Tuple[torch.Tensor, torch.Tensor]
Transformed values and variances.
- class PCA(variance: float)[source]
Bases:
objectPrincipal Component Analysis transformation.
- fit(data: Tensor, covariances: Tensor) None[source]
Fit the PCA transformation to the given data.
Parameters
- datatorch.Tensor
Data to fit the PCA transformation to.
- covariancestorch.Tensor
Covariances of the data to fit the PCA transformation to.
- to(device: str) PCA[source]
Move the PCA to a given device.
Parameters
- devicestr
Device to move the PCA to.
Returns
- PCA
The PCA in the new device.
- transform(values: torch.Tensor, covariances: torch.Tensor | None = None) torch.Tensor | Tuple[torch.Tensor, torch.Tensor][source]
Transform data to the latent space.
Parameters
- valuestorch.Tensor
Values to transform.
- covariancestorch.Tensor | None
Variances to transform, if any.
Returns
- torch.Tensor | Tuple[torch.Tensor, torch.Tensor]
Transformed values and covariances (if any).
- class Standardiser(std_tol: float = 1e-06)[source]
Bases:
objectStandardisation transformation.
- fit(data: Tensor) None[source]
Fit the standardisation transformation to the given data.
Parameters
- datatorch.Tensor
Data to fit the standardisation transformation to.
- to(device: str) Standardiser[source]
Move the standardiser to a given device.
Parameters
- devicestr
Device to move the standardiser to.
Returns
- Standardiser
The standardiser in the new device.
- transform(values: torch.Tensor, covariances: torch.Tensor | None = None) torch.Tensor | Tuple[torch.Tensor, torch.Tensor][source]
Standardise data.
Parameters
- valuestorch.Tensor
Values to transform.
- covariancestorch.Tensor | None
Variances to transform, if any.
Returns
- torch.Tensor | Tuple[torch.Tensor, torch.Tensor]
Transformed values and covariances (if any).