|
| | ModelCluster ()=default |
| |
| void | set (std::shared_ptr< covariance::Covariance > kernel, std::shared_ptr< mean::Mean > mean, Eigen::VectorXd parameters, double nugget, double gamma, unsigned int seed) |
| | Configures parameters, kernel, and random seed for the clustered local GP model.
|
| |
| void | condition (const Eigen::Ref< const Eigen::MatrixXd > &xObs, const Eigen::Ref< const Eigen::VectorXd > &yObs, const Eigen::Ref< const Eigen::VectorXs > &labels) |
| | Conditions the model on observations and initial cluster labels.
|
| |
| std::pair< double, double > | predict (const Eigen::VectorXd &xStar, cmp::classifier::Classifier *classifier) const |
| |
| size_t | nClusters () const |
| |
| void | fit (Eigen::Ref< const Eigen::VectorXd > lowerBound, Eigen::Ref< const Eigen::VectorXd > upperBound, cmp::gp::method fitType, nlopt::algorithm algorithm=nlopt::LN_SBPLX, double tol=1e-3, std::shared_ptr< cmp::prior::Prior > prior=nullptr, std::vector< bool > logScale={}) |
| |
| size_t | nPoints () const |
| |
| size_t | dim () const |
| |
| size_t | getMembership (size_t i) const |
| |
| const Eigen::VectorXs & | getLabels () const |
| |
| size_t | getClusterSize (size_t i) const |
| |
| cmp::gp::GaussianProcess & | operator[] (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) |
| |
| bool | performSwitches (const std::vector< std::pair< size_t, size_t > > &newOwners, size_t minSize) |
| |
| double | computeScore (size_t globalIndex) const |
| |
| double | computeScore (size_t clusterIndex, size_t globalIndex) const |
| |
| std::vector< std::pair< size_t, size_t > > | switchStep (cmp::classifier::Classifier *classifier, size_t maxAllowedSwitches=10, double minProb=0.1, double T=1.0) |
| |
| std::vector< std::pair< size_t, size_t > > | deterministicSwitchStep (cmp::classifier::Classifier *cls, const size_t &maxAllowedSwitches, const double &minProb) |
| |
| void | purge (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 | merge (const size_t &clusterIndex1, const size_t &clusterIndex2) |
| |
Manages a clustered set of Gaussian Processes for localized regression.
$.
For a query point $x^*$, a classifier predicts the probability of cluster membership $P(C = k \mid x^*)$. The blended prediction is given by:
\[
\mu(x^*) = \sum_{k=1}^K P(C = k \mid x^*) \mu_k(x^*)
\]
\[
\sigma^2(x^*) = \sum_{k=1}^K P(C = k \mid x^*)^2 \sigma_k^2(x^*)
\]
where $\mu_k(x^*)$ and $\sigma_k^2(x^*)$ are the mean and variance predictions of the $k$-th GP.
Switching steps evaluate the change in predictive log-likelihood (LOO error for current cluster, or standard predictive log-likelihood for candidate clusters). The stochastic switching probability for point $i$ to cluster $j$ is computed as:
\[
p_{ij} \propto P(C = j \mid x_i) \exp\left( \frac{\Delta_{ij}}{T} \right)
\]
where $\Delta_{ij}$ represents the log-predictive score difference if point $i$ is moved to cluster $j$, and $T$ is the temperature parameter.
Implementation Algorithm
- **Initialization (
condition)**: Groups the input observations according to their labels, instantiates the GP models, computes initial cluster centroids, and sets up index lookup tables.
- **Blended Prediction (
predict)**: Obtains probabilities from the classifier, queries predictions from each local GP, and performs the weighted combination.
- **Stochastic Switching (
switchStep)**: Precomputes probability distributions for all points based on likelihood shifts, filters active points, and samples switches up to maxAllowedSwitches.
- **Deterministic Switching (
deterministicSwitchStep)**: Calculates the log-likelihood gain for all possible re-assignments, sorts them, and executes the top beneficial moves.
Purging / Merging: Reassigns points from a dissolved cluster to their nearest centroids, shrinks the list of active GPs, and shifts all cluster labels to maintain contiguous indices.
Mathematical Formulation Let the dataset be composed of $N$ observations $(x_i, y_i) \in \mathbb{R}^d \times \mathbb{R}$. The data is partitioned into $K$ clusters. Each cluster $k \in 1, \ldots, K