Gaussian process is a stochastical model. More...
#include <GaussianProcess.h>
Public Member Functions | |
GaussianProcess (size_t dims, double sigma, Random &rngRef) | |
Constructor. | |
void | setDimension (size_t dims) |
Change input dimension. | |
void | clear () |
Discard all evidence. | |
size_t | numEvidence () const |
Get the number of evidence provided. | |
std::pair< const std::vector< Vector > &, const Vector & > | getEvidence () const |
Get all currently stored evidence. | |
void | addEvidence (const Vector &input, double output, bool tuneHypers) |
Provide a input-output pair as evidence. | |
const Vector & | getEvidenceMax () const |
Get the evidence with the highest output value. | |
double | predictMean (const Vector &input) const |
Try to predict f(x) using the evidence provided so far. | |
double | getDefaultVar () const |
Get the variance if evidence are ignored. | |
double | predictVar (const Vector &input) const |
The variance of the predicted f(x) from predictMean(). | |
double | predictOutputPDF (const Vector &input, double output) const |
Calculate the probability density of provided output given provided input. | |
double | predictOutputScaledPDF (const Vector &input, double output) const |
Calculate the scaled probability density of provided output given provided input. | |
double | calcAcquisition (AcquisitionFunctionOption af, const Vector &input) const |
Calculates the acquisition function for given input. | |
Vector | sampleAquisitionMax (AcquisitionFunctionOption af, const std::vector< Vector > &samples) const |
Find the input in samples which maximizes given aquisition function. | |
std::vector< GaussianHyperparameters > & | getHyperparameters () |
Get current hyperparameters. | |
void | setHyperparameters (const std::vector< double > &sample_means, const std::vector< double > &sample_thetas, const std::vector< autopas::GaussianProcess::Vector > &sample_dimScales) |
Set the hyperparameters: means, theta, dimScale. | |
void | normalizeHyperparameters () |
Normalize weights of hyperparameters and truncate lowest weights. | |
Static Public Member Functions | |
static std::tuple< std::vector< double >, std::vector< double >, std::vector< autopas::GaussianProcess::Vector > > | generateHyperparameterSamples (size_t sampleSize, Random &rng, size_t dims, double sigma, double evidenceMinValue, double evidenceMaxValue) |
Generate hyperparameter samples. | |
Gaussian process is a stochastical model.
It predicts the output of a blackbox function f(x) for given input x. To do so, some sample input-output pairs (x,f(x)) should be provided as evidence.
Currently the squared exponential kernel is used. TODO: maybe offer some options.
autopas::GaussianProcess::GaussianProcess | ( | size_t | dims, |
double | sigma, | ||
Random & | rngRef | ||
) |
Constructor.
dims | number of input dimensions |
sigma | fixed noise |
rngRef | reference to rng |
void autopas::GaussianProcess::addEvidence | ( | const Vector & | input, |
double | output, | ||
bool | tuneHypers | ||
) |
Provide a input-output pair as evidence.
Each evidence improve the quality of future predictions.
input | x |
output | f(x) |
tuneHypers | if false hyperparemeters need to be set manually |
double autopas::GaussianProcess::calcAcquisition | ( | AcquisitionFunctionOption | af, |
const Vector & | input | ||
) | const |
Calculates the acquisition function for given input.
af | acquisition function a:input->double |
input | i |
|
static |
Generate hyperparameter samples.
sampleSize | size |
rng | random number generator |
dims | number of input dimension |
sigma | fixed noise |
evidenceMinValue | current lowest evidence output |
evidenceMaxValue | current highest evidence output |
double autopas::GaussianProcess::getDefaultVar | ( | ) | const |
Get the variance if evidence are ignored.
std::pair< const std::vector< autopas::GaussianProcess::Vector > &, const autopas::GaussianProcess::Vector & > autopas::GaussianProcess::getEvidence | ( | ) | const |
Get all currently stored evidence.
const autopas::GaussianProcess::Vector & autopas::GaussianProcess::getEvidenceMax | ( | ) | const |
Get the evidence with the highest output value.
std::vector< autopas::GaussianHyperparameters > & autopas::GaussianProcess::getHyperparameters | ( | ) |
Get current hyperparameters.
size_t autopas::GaussianProcess::numEvidence | ( | ) | const |
Get the number of evidence provided.
double autopas::GaussianProcess::predictMean | ( | const Vector & | input | ) | const |
Try to predict f(x) using the evidence provided so far.
input | x |
double autopas::GaussianProcess::predictOutputPDF | ( | const Vector & | input, |
double | output | ||
) | const |
Calculate the probability density of provided output given provided input.
input | |
output |
double autopas::GaussianProcess::predictOutputScaledPDF | ( | const Vector & | input, |
double | output | ||
) | const |
Calculate the scaled probability density of provided output given provided input.
The probability density is scaled such that the maximum is 1.
input | |
output |
double autopas::GaussianProcess::predictVar | ( | const Vector & | input | ) | const |
autopas::GaussianProcess::Vector autopas::GaussianProcess::sampleAquisitionMax | ( | AcquisitionFunctionOption | af, |
const std::vector< Vector > & | samples | ||
) | const |
Find the input in samples which maximizes given aquisition function.
TODO: maybe add parameters for hyperparameters of aquisition functions
af | function to maximize |
samples |
void autopas::GaussianProcess::setDimension | ( | size_t | dims | ) |
Change input dimension.
Current evidence will be discarded.
dims |
void autopas::GaussianProcess::setHyperparameters | ( | const std::vector< double > & | sample_means, |
const std::vector< double > & | sample_thetas, | ||
const std::vector< autopas::GaussianProcess::Vector > & | sample_dimScales | ||
) |
Set the hyperparameters: means, theta, dimScale.
The samples are scored equal to the probability that given evidence and hyperparameter-sample generates given output. Hyperparameters weights should be normalized.
sample_means | |
sample_thetas | |
sample_dimScales |