CMP++: Uncertainty Quantification & Bayesian Calibration
Loading...
Searching...
No Matches
cmp::ModelClusterPoly Class Reference

Manages a clustered set of Polynomial Chaos Expansion (PCE) models for localized regression. More...

#include <model_cluster_poly.h>

Public Member Functions

 ModelClusterPoly ()=default
 
 ~ModelClusterPoly ()=default
 
void set (std::vector< cmp::PolynomialExpansion > *polynomials, const double &gamma=0, const double &seed=42)
 
void condition (const Eigen::Ref< const Eigen::MatrixXd > &xObs, const Eigen::Ref< const Eigen::VectorXd > &yObs, const Eigen::Ref< const Eigen::VectorXs > &labels)
 
size_t nClusters () const
 
void fit ()
 
size_t nPoints () const
 
size_t dim () const
 
size_t getMembership (size_t i) const
 
const Eigen::VectorXsgetLabels () const
 
size_t getClusterSize (size_t i) const
 
cmp::PolynomialExpansionoperator[] (size_t i)
 
const Eigen::VectorXd & centroid (size_t i) const
 
Eigen::VectorXs getIndices (size_t clusterIndex) const
 
void updateModel (const std::vector< bool > &affectedClusters)
 
void performSwitches (const std::vector< std::pair< size_t, size_t > > &newOwners)
 
bool isFit (const size_t &clusterIndex) const
 
void setFit (const size_t &clusterIndex, const bool &fit)
 
double computeScore (size_t globalIndex) const
 
double computeScore (size_t model, size_t globalIndex) const
 
std::vector< std::pair< size_t, size_t > > switchStep (cmp::classifier::Classifier *classifier, const double &T=1.0, const size_t &maxAllowedSwitches=10, const double &minProb=0.1)
 
std::vector< std::pair< size_t, size_t > > deterministicSwitchStep (cmp::classifier::Classifier *cls, const size_t &maxAllowedSwitches, const double &minProb)
 
void purgeStep (const size_t &clusterIndex)
 
std::vector< std::vector< double > > computeProbabilities (const double &T, cmp::classifier::Classifier *classifier, const double &minProb=0.1) const
 
Eigen::MatrixXd confusionMatrix (std::vector< std::vector< double > > switchingProbability) const
 
void mergeClusters (const size_t &clusterIndex1, const size_t &clusterIndex2, bool hparGuess=false)
 

Private Attributes

std::default_random_engine rng_
 Pseudo-random number generator.
 
Eigen::MatrixXd xObs_
 Training input matrix of observations.
 
Eigen::VectorXd yObs_
 Training target response vector.
 
size_t nClusters_
 Number of active clusters.
 
size_t nObs_
 Number of training observations.
 
size_t dimX_
 Dimension of input features.
 
Eigen::VectorXs labels_
 Cluster assignments label vector.
 
Eigen::VectorXs localIndexTable_
 Local coordinate lookup index mapping.
 
std::vector< boolfit_
 Cluster fit/convergence status flag vector.
 
std::vector< Eigen::VectorXd > centroids_
 Coordinates for each cluster's centroid.
 
std::vector< cmp::PolynomialExpansion > * polynomials_
 Polynomial expansions representing local models.
 
std::vector< size_tclusterSize_
 Number of points assigned to each cluster.
 
double gamma_ {1.0}
 Regularization blending parameter gamma.
 

Detailed Description

Manages a clustered set of Polynomial Chaos Expansion (PCE) models for localized regression.

Mathematical Formulation Partitions the input dataset \(\mathcal{D} = \{(\mathbf{x}_i, y_i)\}_{i=1}^N\) into \(K\) localized clusters. For each cluster \(k \in \{0, \dots, K-1\}\), it fits a localized Polynomial Chaos Expansion surrogate:

\[ Y^{(k)}(\boldsymbol{\xi}) \approx \sum_{j=0}^{P-1} c_j^{(k)} \Psi_j^{(k)}(\boldsymbol{\xi}) \]

where \(\Psi_j^{(k)}\) is the orthonormal polynomial basis for cluster \(k\), and \(c_j^{(k)}\) are the local expansion coefficients. For a test query \(\mathbf{x}^*\), local predictions are combined using the classifier's posterior probabilities \(P(C=k \mid \mathbf{x}^*)\):

\[ \mu(\mathbf{x}^*) = \sum_{k=1}^K P(C=k \mid \mathbf{x}^*) \mu_k(\mathbf{x}^*) \]

where \(\mu_k(\mathbf{x}^*)\) is the output of the \(k\)-th local PCE model.

Implementation Algorithm

  1. condition() groups training inputs according to active clusters and solves the local spectral projection or regression to estimate coefficients \(c_j^{(k)}\).
  2. predict() obtains classifier probabilities and computes the weighted average of local polynomial evaluations.

Constructor & Destructor Documentation

◆ ModelClusterPoly()

cmp::ModelClusterPoly::ModelClusterPoly ( )
default

◆ ~ModelClusterPoly()

cmp::ModelClusterPoly::~ModelClusterPoly ( )
default

Member Function Documentation

◆ centroid()

const Eigen::VectorXd & cmp::ModelClusterPoly::centroid ( size_t  i) const
inline

◆ computeProbabilities()

std::vector< std::vector< double > > cmp::ModelClusterPoly::computeProbabilities ( const double T,
cmp::classifier::Classifier classifier,
const double minProb = 0.1 
) const
inline

◆ computeScore() [1/2]

double cmp::ModelClusterPoly::computeScore ( size_t  globalIndex) const
inline

This function computes the owner-cluster LOO score for point globalIndex.

◆ computeScore() [2/2]

double cmp::ModelClusterPoly::computeScore ( size_t  model,
size_t  globalIndex 
) const
inline

This function computes the score of cluster model on point globalIndex.

◆ condition()

void cmp::ModelClusterPoly::condition ( const Eigen::Ref< const Eigen::MatrixXd > &  xObs,
const Eigen::Ref< const Eigen::VectorXd > &  yObs,
const Eigen::Ref< const Eigen::VectorXs > &  labels 
)
inline

◆ confusionMatrix()

Eigen::MatrixXd cmp::ModelClusterPoly::confusionMatrix ( std::vector< std::vector< double > >  switchingProbability) const
inline

◆ deterministicSwitchStep()

std::vector< std::pair< size_t, size_t > > cmp::ModelClusterPoly::deterministicSwitchStep ( cmp::classifier::Classifier cls,
const size_t maxAllowedSwitches,
const double minProb 
)
inline

◆ dim()

size_t cmp::ModelClusterPoly::dim ( ) const
inline

◆ fit()

void cmp::ModelClusterPoly::fit ( )
inline

◆ getClusterSize()

size_t cmp::ModelClusterPoly::getClusterSize ( size_t  i) const
inline

◆ getIndices()

Eigen::VectorXs cmp::ModelClusterPoly::getIndices ( size_t  clusterIndex) const
inline

◆ getLabels()

const Eigen::VectorXs & cmp::ModelClusterPoly::getLabels ( ) const
inline

◆ getMembership()

size_t cmp::ModelClusterPoly::getMembership ( size_t  i) const
inline

◆ isFit()

bool cmp::ModelClusterPoly::isFit ( const size_t clusterIndex) const
inline

◆ mergeClusters()

void cmp::ModelClusterPoly::mergeClusters ( const size_t clusterIndex1,
const size_t clusterIndex2,
bool  hparGuess = false 
)
inline

◆ nClusters()

size_t cmp::ModelClusterPoly::nClusters ( ) const
inline

◆ nPoints()

size_t cmp::ModelClusterPoly::nPoints ( ) const
inline

◆ operator[]()

◆ performSwitches()

void cmp::ModelClusterPoly::performSwitches ( const std::vector< std::pair< size_t, size_t > > &  newOwners)
inline

This function performs the switch of the points

Parameters
newOwnersThe new owners of the points, the first element is the global index and the second element is the owner

◆ purgeStep()

void cmp::ModelClusterPoly::purgeStep ( const size_t clusterIndex)
inline

This function purges a cluster

Parameters
clusterIndexThe index of the cluster to purge

◆ set()

void cmp::ModelClusterPoly::set ( std::vector< cmp::PolynomialExpansion > *  polynomials,
const double &  gamma = 0,
const double &  seed = 42 
)
inline

◆ setFit()

void cmp::ModelClusterPoly::setFit ( const size_t clusterIndex,
const bool fit 
)
inline

◆ switchStep()

std::vector< std::pair< size_t, size_t > > cmp::ModelClusterPoly::switchStep ( cmp::classifier::Classifier classifier,
const double T = 1.0,
const size_t maxAllowedSwitches = 10,
const double minProb = 0.1 
)
inline

◆ updateModel()

void cmp::ModelClusterPoly::updateModel ( const std::vector< bool > &  affectedClusters)
inline

Member Data Documentation

◆ centroids_

std::vector<Eigen::VectorXd> cmp::ModelClusterPoly::centroids_
private

Coordinates for each cluster's centroid.

◆ clusterSize_

std::vector<size_t> cmp::ModelClusterPoly::clusterSize_
private

Number of points assigned to each cluster.

◆ dimX_

size_t cmp::ModelClusterPoly::dimX_
private

Dimension of input features.

◆ fit_

std::vector<bool> cmp::ModelClusterPoly::fit_
private

Cluster fit/convergence status flag vector.

◆ gamma_

double cmp::ModelClusterPoly::gamma_ {1.0}
private

Regularization blending parameter gamma.

◆ labels_

Eigen::VectorXs cmp::ModelClusterPoly::labels_
private

Cluster assignments label vector.

◆ localIndexTable_

Eigen::VectorXs cmp::ModelClusterPoly::localIndexTable_
private

Local coordinate lookup index mapping.

◆ nClusters_

size_t cmp::ModelClusterPoly::nClusters_
private

Number of active clusters.

◆ nObs_

size_t cmp::ModelClusterPoly::nObs_
private

Number of training observations.

◆ polynomials_

std::vector<cmp::PolynomialExpansion>* cmp::ModelClusterPoly::polynomials_
private

Polynomial expansions representing local models.

◆ rng_

std::default_random_engine cmp::ModelClusterPoly::rng_
private

Pseudo-random number generator.

◆ xObs_

Eigen::MatrixXd cmp::ModelClusterPoly::xObs_
private

Training input matrix of observations.

◆ yObs_

Eigen::VectorXd cmp::ModelClusterPoly::yObs_
private

Training target response vector.


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