Dakota  Version
Explore and Predict with Confidence
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
PolynomialRegression Class Reference

The PolynomialRegression class constructs a polynomial regressor using ordinary least squares. More...

Inheritance diagram for PolynomialRegression:
Surrogate PyPolyReg

Public Member Functions

 PolynomialRegression ()
 Constructor that uses defaultConfigOptions and does not build.
 
 PolynomialRegression (const ParameterList &options)
 Constructor that sets configOptions and does not build. More...
 
 PolynomialRegression (const std::string &param_list_yaml_filename)
 Constructor for the PolynomialRegression class that sets configOptions but does not build the surrogate. More...
 
 PolynomialRegression (const MatrixXd &samples, const MatrixXd &response, const ParameterList &options)
 Constructor sets configOptions and builds the Polynomial Regression surrogate. More...
 
 PolynomialRegression (const MatrixXd &samples, const MatrixXd &response, const std::string &param_list_yaml_filename)
 Constructor for the PolynomialRegression class that sets configOptions and builds the surrogate. More...
 
 ~PolynomialRegression ()
 Default destructor.
 
void compute_basis_matrix (const MatrixXd &samples, MatrixXd &basis_matrix) const
 Constructs a basis matrix for a set of samples according to the member variable basisIndices. More...
 
void build (const MatrixXd &samples, const MatrixXd &response) override
 Build the polynomial surrogate using specified build data. More...
 
VectorXd value (const MatrixXd &eval_points, const int qoi) override
 Evaluate the polynomial surrogate at a set of prediction points for a single QoI. More...
 
VectorXd value (const MatrixXd &eval_points)
 Evaluate the polynomial surrogate at a set of prediction points for QoI index 0. More...
 
MatrixXd gradient (const MatrixXd &eval_points, const int qoi) override
 Evaluate the gradient of the polynomial surrogate at a set of prediction points for a single QoI. More...
 
MatrixXd gradient (const MatrixXd &eval_points)
 Evaluate the gradient of the polynomial surrogate at a set of prediction points for QoI index 0. More...
 
MatrixXd hessian (const MatrixXd &eval_point, const int qoi) override
 Evaluate the Hessian of the polynomial surrogate at a single point for a single QoI. More...
 
MatrixXd hessian (const MatrixXd &eval_point)
 Evaluate the Hessian of the polynomial surrogate at a single point for QoI index 0. More...
 
const MatrixXdget_polynomial_coeffs () const
 Get the polynomial surrogate's coefficients.
 
double get_polynomial_intercept () const
 Get the polynomial surrogate's intercept/offset.
 
int get_num_terms () const
 Get the number of terms in the polynomial surrogate.
 
void set_polynomial_coeffs (const MatrixXd &coeffs)
 Set the polynomial surrogate's coefficients.
 
std::shared_ptr< Surrogateclone () const override
 clone derived Surrogate class for use in cross-validation
 
- Public Member Functions inherited from Surrogate
 Surrogate ()
 Constructor that uses defaultConfigOptions and does not build.
 
 Surrogate (const ParameterList &param_list)
 Constructor that sets configOptions but does not build. More...
 
 Surrogate (const MatrixXd &samples, const MatrixXd &response, const ParameterList &param_list)
 Constructor for the Surrogate that sets configOptions and builds the surrogate (does nothing in the base class). More...
 
virtual ~Surrogate ()
 Default destructor.
 
VectorXd value (const MatrixXd &eval_points)
 Evaluate the Surrogate at a set of prediction points for QoI index 0. More...
 
MatrixXd gradient (const MatrixXd &eval_points)
 Evaluate the gradient of the Surrogate at a set of prediction points for QoI index 0. More...
 
MatrixXd hessian (const MatrixXd &eval_point)
 Evaluate the Hessian of the Surrogate at a single point for QoI index 0. More...
 
void variable_labels (const std::vector< std::string > &var_labels)
 Set the variable/feature names. More...
 
const std::vector< std::string > & variable_labels () const
 Get the (possibly empty) variable/feature names. More...
 
void response_labels (const std::vector< std::string > &resp_labels)
 Set the response/QoI names. More...
 
const std::vector< std::string > & response_labels () const
 Get the (possibly empty) response/QoI names. More...
 
void set_options (const ParameterList &options)
 Set the Surrogate's configOptions. More...
 
void get_options (ParameterList &options)
 Get the Surrogate's configOptions. More...
 
void print_options ()
 Print the Surrogate's configOptions.
 
VectorXd evaluate_metrics (const StringArray &mnames, const MatrixXd &points, const MatrixXd &ref_values)
 Evalute metrics at specified points (within surrogates)
 
VectorXd cross_validate (const MatrixXd &samples, const MatrixXd &response, const StringArray &mnames, const int num_folds=5, const int seed=20)
 Perform K-folds cross-validation (within surrogates)
 
template<typename DerivedSurr >
void save (const DerivedSurr &surr_out, const std::string &outfile, const bool binary)
 Serialize a derived (i.e. non-base) surrogate model. More...
 
template<typename DerivedSurr >
void load (const std::string &infile, const bool binary, DerivedSurr &surr_in)
 Load a derived (i.e. non-base) surrogate model. More...
 

Private Member Functions

void default_options () override
 Construct and populate the defaultConfigOptions.
 
template<class Archive >
void serialize (Archive &archive, const unsigned int version)
 Serializer for save/load.
 

Private Attributes

MatrixXi basisIndices
 Matrix that specifies the powers of each variable for each term in the polynomial - (numVariables by numTerms).
 
std::shared_ptr< util::LinearSolverBaselinearSolver
 Linear solver for the ordinary least squares problem.
 
int numTerms
 Number of terms in the polynomial basis.
 
MatrixXd polynomialCoeffs
 Vector of coefficients for the polynomial surrogate.
 
double polynomialIntercept
 Offset/intercept term for the polynomial surrogate.
 
int verbosity
 Verbosity level.
 

Friends

class boost::serialization::access
 Allow serializers access to private class data.
 

Additional Inherited Members

- Static Public Member Functions inherited from Surrogate
template<typename SurrHandle >
static void save (const SurrHandle &surr_out, const std::string &outfile, const bool binary)
 serialize Surrogate to file (typically through shared_ptr<Surrogate>, but Derived& or Derived* okay too)
 
template<typename SurrHandle >
static void load (const std::string &infile, const bool binary, SurrHandle &surr_in)
 serialize Surrogate from file (typically through shared_ptr<Surrogate>, but Derived& or Derived* okay too)
 
static std::shared_ptr< Surrogateload (const std::string &infile, const bool binary)
 serialize Surrogate from file through pointer to base class (must have been saved via same data type)
 
- Public Attributes inherited from Surrogate
util::DataScaler dataScaler
 DataScaler class for a Surrogate's build samples.
 
double responseOffset = 0.
 Response offset.
 
double responseScaleFactor = 1.
 Response scale factor.
 
- Protected Attributes inherited from Surrogate
int numSamples
 Number of samples in the Surrogate's build samples.
 
int numVariables
 Number of features/variables in the Surrogate's build samples.
 
std::vector< std::string > variableLabels
 Names of the variables/features; need not be populated.
 
int numQOI
 Number of quantities of interest predicted by the surrogate. For scalar-valued surrogates numQOI = 1.
 
std::vector< std::string > responseLabels
 Names of the responses/QoIs; need not be populated.
 
ParameterList defaultConfigOptions
 Default Key/value options to configure the surrogate.
 
ParameterList configOptions
 Key/value options to configure the surrogate - will override defaultConfigOptions.
 

Detailed Description

The PolynomialRegression class constructs a polynomial regressor using ordinary least squares.

Users may specify the max degree and p-norm for a hyperbolic cross scheme to specify the terms in the polynomial basis. A p-norm = 1 results in a total order specification of max degree.

The DataScaler class provides the option of scaling the basis matrix.

Constructor & Destructor Documentation

◆ PolynomialRegression() [1/4]

PolynomialRegression ( const ParameterList options)

Constructor that sets configOptions and does not build.

Parameters
[in]optionsList that overrides entries in defaultConfigOptions.

References Surrogate::configOptions, PolynomialRegression::default_options(), and Surrogate::defaultConfigOptions.

◆ PolynomialRegression() [2/4]

PolynomialRegression ( const std::string &  param_list_yaml_filename)

Constructor for the PolynomialRegression class that sets configOptions but does not build the surrogate.

Parameters
[in]param_list_yaml_filenameA ParameterList file (relative to the location of the Dakota input file) that overrides entries in defaultConfigOptions.

References Surrogate::configOptions, PolynomialRegression::default_options(), and Surrogate::defaultConfigOptions.

◆ PolynomialRegression() [3/4]

PolynomialRegression ( const MatrixXd samples,
const MatrixXd response,
const ParameterList options 
)

Constructor sets configOptions and builds the Polynomial Regression surrogate.

Parameters
[in]samplesMatrix of data for surrogate construction - (num_samples by num_features)
[in]responseVector of targets for surrogate construction - (num_samples by num_qoi = 1; only 1 response is supported currently).
[in]optionsList that overrides entries in defaultConfigOptions

References PolynomialRegression::build(), Surrogate::configOptions, and PolynomialRegression::default_options().

◆ PolynomialRegression() [4/4]

PolynomialRegression ( const MatrixXd samples,
const MatrixXd response,
const std::string &  param_list_yaml_filename 
)

Constructor for the PolynomialRegression class that sets configOptions and builds the surrogate.

Parameters
[in]samplesMatrix of data for surrogate construction - (num_samples by num_features)
[in]responseVector of targets for surrogate construction - (num_samples by num_qoi = 1; only 1 response is supported currently).
[in]param_list_yaml_filenameA ParameterList file (relative to the location of the Dakota input file) that overrides entries in defaultConfigOptions.

References PolynomialRegression::build(), Surrogate::configOptions, and PolynomialRegression::default_options().

Member Function Documentation

◆ compute_basis_matrix()

void compute_basis_matrix ( const MatrixXd samples,
MatrixXd basis_matrix 
) const

Constructs a basis matrix for a set of samples according to the member variable basisIndices.

Parameters
[in]samplesMatrix of sample points - (num_points by num_features).
[out]basis_matrixMatrix that contains polynomial basis function evaluations in its rows for each sample point - (num_points by numTerms), numTerms being the number of terms in the polynomial basis.

References PolynomialRegression::basisIndices, PolynomialRegression::numTerms, and Surrogate::numVariables.

Referenced by PolynomialRegression::build(), PolynomialRegression::gradient(), PolynomialRegression::hessian(), and PolynomialRegression::value().

◆ build()

void build ( const MatrixXd samples,
const MatrixXd response 
)
overridevirtual

◆ value() [1/2]

VectorXd value ( const MatrixXd eval_points,
const int  qoi 
)
overridevirtual

Evaluate the polynomial surrogate at a set of prediction points for a single QoI.

Parameters
[in]eval_pointsMatrix of prediction points - (num_pts by num_features).
[in]qoiIndex for surrogate QoI.
Returns
Values of the polynomial surrogate at the prediction points - (num_pts)

Implements Surrogate.

References PolynomialRegression::compute_basis_matrix(), Surrogate::dataScaler, PolynomialRegression::polynomialCoeffs, PolynomialRegression::polynomialIntercept, Surrogate::responseOffset, Surrogate::responseScaleFactor, DataScaler::scale_samples(), and dakota::silence_unused_args().

Referenced by Dakota::compute_regression_coeffs().

◆ value() [2/2]

VectorXd value ( const MatrixXd eval_points)
inline

Evaluate the polynomial surrogate at a set of prediction points for QoI index 0.

Parameters
[in]eval_pointsMatrix of prediction points - (num_pts by num_features).
Returns
Values of the polynomial surrogate at the prediction points - (num_pts)

References Surrogate::value().

◆ gradient() [1/2]

MatrixXd gradient ( const MatrixXd eval_points,
const int  qoi 
)
overridevirtual

Evaluate the gradient of the polynomial surrogate at a set of prediction points for a single QoI.

Parameters
[in]eval_pointsCoordinates of the prediction points - (num_pts by num_features).
[in]qoiIndex of response/QOI for which to compute derivatives.
Returns
Matrix of gradient vectors at the prediction points - (num_pts by num_features).

Reimplemented from Surrogate.

References PolynomialRegression::basisIndices, PolynomialRegression::compute_basis_matrix(), Surrogate::dataScaler, PolynomialRegression::numTerms, Surrogate::numVariables, PolynomialRegression::polynomialCoeffs, Surrogate::responseScaleFactor, DataScaler::scale_samples(), and dakota::silence_unused_args().

◆ gradient() [2/2]

MatrixXd gradient ( const MatrixXd eval_points)
inline

Evaluate the gradient of the polynomial surrogate at a set of prediction points for QoI index 0.

Parameters
[in]eval_pointsCoordinates of the prediction points - (num_pts by num_features).
Returns
Matrix of gradient vectors at the prediction points - (num_pts by num_features).

References Surrogate::gradient().

◆ hessian() [1/2]

MatrixXd hessian ( const MatrixXd eval_point,
const int  qoi 
)
overridevirtual

Evaluate the Hessian of the polynomial surrogate at a single point for a single QoI.

Parameters
[in]eval_pointCoordinates of the prediction point - (1 by num_features).
[in]qoiIndex of response/QOI for which to compute derivatives.
Returns
Hessian matrix at the prediction point - (num_features by num_features).

Reimplemented from Surrogate.

References PolynomialRegression::basisIndices, PolynomialRegression::compute_basis_matrix(), Surrogate::dataScaler, PolynomialRegression::numTerms, Surrogate::numVariables, PolynomialRegression::polynomialCoeffs, Surrogate::responseScaleFactor, DataScaler::scale_samples(), and dakota::silence_unused_args().

◆ hessian() [2/2]

MatrixXd hessian ( const MatrixXd eval_point)
inline

Evaluate the Hessian of the polynomial surrogate at a single point for QoI index 0.

Parameters
[in]eval_pointCoordinates of the prediction point - (1 by num_features).
Returns
Hessian matrix at the prediction point - (num_features by num_features).

References Surrogate::hessian().


The documentation for this class was generated from the following files: