Thesis docs
|
Dirichlet Process with spatial Weights class for spatially-aware Bayesian nonparametric clustering. More...
#include <DPW.hpp>
Public Member Functions | |
DPW (Data &d, Params &p) | |
Constructor for the Dirichlet Process with spatial Weights. | |
void | update_params () override |
Updates the parameters of the Dirichlet Process with spatial Weights. | |
Gibbs Sampling Methods | |
double | gibbs_prior_existing_cluster (int cls_idx, int obs_idx) const override |
Computes the log prior probability of assigning a data point to an existing cluster. | |
Eigen::VectorXd | gibbs_prior_existing_clusters (int obs_idx) const override |
Computes the log prior probabilities of assigning a data point to every existing cluster. This method is useful for Gibbs sampling over existing clusters. It returns a vector of log prior probabilities for all existing clusters. | |
double | gibbs_prior_new_cluster () const override |
Computes the log prior probability of assigning a data point to a new cluster. | |
Split-Merge Algorithm Methods | |
double | prior_ratio_split (int ci, int cj) const override |
Computes the prior ratio for a split operation in a spatially-aware split-merge MCMC algorithm. | |
double | prior_ratio_merge (int size_old_ci, int size_old_cj) const override |
Computes the prior ratio for a merge operation in a spatially-aware split-merge MCMC algorithm. | |
double | prior_ratio_shuffle (int size_old_ci, int size_old_cj, int ci, int cj) const override |
Computes the prior ratio for a shuffle operation in a spatially-aware split-merge MCMC algorithm. | |
Spatial Methods | |
int | get_neighbors_obs (int obs_idx, int cls_idx) const |
Returns the number of neighbors for a given observation in a specific cluster. | |
Eigen::VectorXi | get_neighbors_obs (int obs_idx) const |
Returns the number of neighbors for a given observation regardless of cluster membership. This method counts the total number of neighbors of an observation based on the adjacency matrix W. | |
int | get_neighbors_cls (int cls_idx, bool old_allo=false) const |
Returns the total number of neighbors for all observations in a given cluster. | |
![]() | |
Process (Data &d, Params &p) | |
Constructor initializing process with data and parameters. | |
void | set_old_allocations (const Eigen::VectorXi &new_allocations) |
Store current allocations for potential rollback. | |
void | set_idx_i (int i) |
Set index of first observation in split-merge pair. | |
void | set_idx_j (int j) |
Set index of second observation in split-merge pair. | |
virtual | ~Process () |
Virtual destructor for proper cleanup of derived classes. | |
Additional Inherited Members | |
![]() | |
Data & | data |
Reference to the data object containing observations and allocations. | |
Params & | params |
Reference to the parameters object containing process hyperparameters. | |
Eigen::VectorXi | old_allocations |
Storage for previous allocations to enable rollback in case of rejection. | |
int | idx_i |
Index of first observation involved in split-merge move. | |
int | idx_j |
Index of second observation involved in split-merge move. | |
const double | log_a = log(params.a) |
Precomputed logarithm of total mass parameter for efficiency. | |
Dirichlet Process with spatial Weights class for spatially-aware Bayesian nonparametric clustering.
This class extends the Dirichlet Process to incorporate spatial information through an adjacency matrix W. It provides methods for Gibbs sampling and split-merge algorithms that account for spatial dependencies between observations in the clustering process.
Constructor for the Dirichlet Process with spatial Weights.
d | Reference to the data object containing observations and cluster assignments. |
p | Reference to the parameters object containing the adjacency matrix W and spatial coefficient. |
int DPW::get_neighbors_cls | ( | int | cls_idx, |
bool | old_allo = false ) const |
Returns the total number of neighbors for all observations in a given cluster.
This method computes the sum of all neighbor connections within a cluster, which is used in the spatial component of the prior calculations.
cls_idx | The index of the cluster. |
old_allo | If true, uses the old allocations for neighbor counting; otherwise, uses current allocations (default: false). |
Returns the total number of neighbors for all observations in a given cluster.
This method computes the sum of all neighbor connections within a cluster, which is used in the spatial component of the prior calculations.
cls_idx | The index of the cluster. |
old_allo | If true, uses the old allocations for neighbor counting; otherwise, uses current allocations. |
Eigen::VectorXi DPW::get_neighbors_obs | ( | int | obs_idx | ) | const |
Returns the number of neighbors for a given observation regardless of cluster membership. This method counts the total number of neighbors of an observation based on the adjacency matrix W.
obs_idx | The index of the observation. |
Returns the number of neighbors for a given observation regardless of cluster membership. This method counts the total number of neighbors of an observation based on the adjacency matrix W.
obs_idx | The index of the observation. |
int DPW::get_neighbors_obs | ( | int | obs_idx, |
int | cls_idx ) const |
Returns the number of neighbors for a given observation in a specific cluster.
This method counts the neighbors of an observation based on the adjacency matrix W, considering only neighbors that belong to the specified cluster.
obs_idx | The index of the observation. |
cls_idx | The index of the cluster to consider for neighbor counting. |
Returns the number of neighbors for a given observation in a specific cluster.
This method counts the neighbors of an observation based on the adjacency matrix W, considering only neighbors that belong to the specified cluster.
obs_idx | The index of the observation. |
cls_idx | The index of the cluster to consider for neighbor counting. |
|
nodiscardoverridevirtual |
Computes the log prior probability of assigning a data point to an existing cluster.
This method incorporates spatial information by considering the number of neighbors in the target cluster when computing the prior probability.
cls_idx | The index of the cluster. |
obs_idx | The index of the observation to assign. |
Computes the log prior probability of assigning a data point to an existing cluster.
This method incorporates spatial information by considering the number of neighbors in the target cluster when computing the prior probability.
cls_idx | The index of the cluster. |
obs_idx | The index of the observation to assign. |
Implements Process.
|
nodiscardoverridevirtual |
Computes the log prior probabilities of assigning a data point to every existing cluster. This method is useful for Gibbs sampling over existing clusters. It returns a vector of log prior probabilities for all existing clusters.
obs_idx | The index of the observation to assign. |
Computes the log prior probabilities of assigning a data point to all existing clusters.
This method incorporates spatial information by considering the number of neighbors in each target cluster when computing the prior probabilities.
obs_idx | The index of the observation to assign. |
Implements Process.
|
nodiscardoverridevirtual |
Computes the log prior probability of assigning a data point to a new cluster.
Computes the log prior probability of assigning a data point to a new cluster.
Implements Process.
|
nodiscardoverridevirtual |
Computes the prior ratio for a merge operation in a spatially-aware split-merge MCMC algorithm.
This method accounts for both the Dirichlet Process prior and spatial dependencies when computing the acceptance ratio for merging clusters.
size_old_ci | The size of the first cluster before the merge. |
size_old_cj | The size of the second cluster before the merge. |
Computes the prior ratio for a merge operation in a spatially-aware split-merge MCMC algorithm.
This method accounts for both the Dirichlet Process prior and spatial dependencies when computing the acceptance ratio for merging clusters.
size_old_ci | The size of the first cluster before the merge. |
size_old_cj | The size of the second cluster before the merge. |
Implements Process.
|
nodiscardoverridevirtual |
Computes the prior ratio for a shuffle operation in a spatially-aware split-merge MCMC algorithm.
This method accounts for both the Dirichlet Process prior and spatial dependencies when computing the acceptance ratio for shuffling observations between clusters.
size_old_ci | The size of the first cluster before the shuffle. |
size_old_cj | The size of the second cluster before the shuffle. |
ci | The first cluster index involved in the shuffle. |
cj | The second cluster index involved in the shuffle. |
Computes the prior ratio for a shuffle operation in a spatially-aware split-merge MCMC algorithm.
This method accounts for both the Dirichlet Process prior and spatial dependencies when computing the acceptance ratio for shuffling observations between clusters.
size_old_ci | The size of the first cluster before the shuffle. |
size_old_cj | The size of the second cluster before the shuffle. |
ci | The first cluster index involved in the shuffle. |
cj | The second cluster index involved in the shuffle. |
Implements Process.
|
nodiscardoverridevirtual |
Computes the prior ratio for a split operation in a spatially-aware split-merge MCMC algorithm.
This method accounts for both the Dirichlet Process prior and spatial dependencies when computing the acceptance ratio for splitting clusters.
ci | The first cluster index involved in the split. |
cj | The second cluster index involved in the split. |
Computes the prior ratio for a split operation in a spatially-aware split-merge MCMC algorithm.
This method accounts for both the Dirichlet Process prior and spatial dependencies when computing the acceptance ratio for splitting clusters.
ci | The first cluster index involved in the split. |
cj | The second cluster index involved in the split. |
Implements Process.
|
inlineoverridevirtual |