---
title: Patient Cohesion-Separation Loss (PCSL)
url: https://www.emergentmind.com/topics/patient-cohesion-separation-loss-pcsl
type: topic
---

# Patient Cohesion-Separation Loss (PCSL)

Patient Cohesion-Separation Loss (PCSL) is a training objective introduced by Jeong and Kim in the context of lung sound classification to address inter-patient variability observable in biomedical signals, even among individuals with similar clinical presentations. Within the Patient-Aware Feature Alignment (PAFA) framework, PCSL explicitly enforces that representations of examples from the same patient are clustered together, while the centroids of different patients are pulled apart in feature space. This mechanism aims to preserve individualized patient signatures during supervised learning, thereby improving generalization and robustness on benchmarks with substantial subject-specific heterogeneity [2505.23834].

## 1. Formal Definition and Mathematical Structure

PCSL operates on mini-batches composed of $M$ samples, each with a patient label $p(i)\in P$. The backbone and projection network $f_\theta(\cdot)$ maps each input $x_i$ (e.g., a Mel-spectrogram) to a feature vector $z_i\in\mathbb{R}^d$. For each patient $p\in P$, let $\mathcal{I}_p = \{i\,|\,p(i)=p\}$ denote the index set for samples from $p$, with $N_p=|\mathcal{I}_p|$, and define the patient-specific centroid:
\[
\mu_p = \frac{1}{N_p} \sum_{i\in\mathcal{I}_p} z_i.
\]
Two statistics are introduced:
- **Intra-patient scatter**:
  \[
  S_W = \sum_{p\in P} \sum_{i\in\mathcal{I}_p} \|z_i - \mu_p\|_2^2
  \]
  which quantifies within-patient variance.
- **Inter-patient scatter**:
  \[
  S_B = \sum_{p\in P}\sum_{q\in P,\,q\ne p}\|\mu_p-\mu_q\|_2^2
  \]
  which quantifies between-centroid separation.

PCSL is then defined as the ratio
\[
\mathcal{L}_{\text{PCSL}} = \frac{S_W}{S_B + \epsilon}
\]
where $\epsilon>0$ is a small constant for numerical stability. Minimizing $\mathcal{L}_{\text{PCSL}}$ drives embeddings for the same patient towards their centroid (reducing $S_W$) and centroids of different patients apart (increasing $S_B$).

## 2. Roles and Interplay of Cohesion and Separation Terms

The two components of PCSL operate antagonistically yet synergistically:
- **Cohesion Term ($S_W$):** Penalizes dispersion of features from the same patient, encouraging tight patient-specific clusters in feature space.
- **Separation Term ($S_B$):** Promotes dispersal among patient centroids, ensuring that patient-specific manifolds do not collapse onto one another.
- **Ratio Formulation:** Simultaneously encourages intra-patient tightness and inter-patient diversity. Reduction of $S_W$ or increase in $S_B$ both independently decrease $\mathcal{L}_{\text{PCSL}}$.
- **Stabilization Factor:** The addition of $\epsilon$, typically $1\text{e}^{-6}$, prevents numerical instability when centroids coalesce early in training.

## 3. Centroid Calculation and Feature Space Dynamics

During each batch, the model executes:
1. Forward pass to obtain $\{z_i\}$.
2. Divides embeddings per patient, determines indices $\mathcal{I}_p$.
3. Computes $\mu_p$ for all $p$ via averaging.
4. Calculates $S_W$, $S_B$, and thus $\mathcal{L}_{\text{PCSL}}$.

Because $\mu_p$ depends on all constituent $z_i$ and thus on network parameters $\theta$, centroid locations evolve throughout training. As optimization progresses, centroids for distinct patients stabilize at well-separated locations if the latent space accommodates individual-variation structure.

## 4. Integration into the Overall Training Objective

PCSL is combined with standard cross-entropy (for supervised class prediction) and the Global Patient Alignment Loss (GPAL), which mildly regularizes all patient centroids toward their grand mean:
\[
\mu_G = \frac{1}{|P|}\sum_{p\in P}\mu_p,\qquad
\mathcal{L}_{\text{GPAL}} = \frac{1}{|P|}\sum_{p\in P}\|\mu_p-\mu_G\|_2^2.
\]
The full objective for the PAFA framework is
\[
\mathcal{L}_{\text{total}} = \mathcal{L}_{\text{CE}} + \lambda_\text{pcsl}\cdot\mathcal{L}_{\text{PCSL}} + \lambda_\text{gpal}\cdot\mathcal{L}_{\text{GPAL}}.
\]
Hyperparameters $\lambda_\text{pcsl}=50$ and $\lambda_\text{gpal}=0.0005$ provided optimal performance in ICBHI experiments via grid search.

## 5. Optimization, Implementation, and Feature Manifold Effects

The backpropagated gradients from $\mathcal{L}_{\text{PCSL}}$ impact features as follows:
- **From $S_W$:** Each $z_i$ is pulled toward its patient centroid $\mu_{p(i)}$.
- **From $S_B$:** Centroid positions, being functions of current embeddings, interact so as to repel each $\mu_p$ from others; each $z_i$ thus indirectly receives a (weaker) push away from non-identical patient centroids.

Efficient computation is possible for practical batch sizes (e.g., $|P|\leq32$); complexity of $S_B$ is $O(|P|^2)$. In batches, if $N_p=1$ (only one sample for a patient), $\mu_p=z_i$ and that sample contributes zero to $S_W$, but still participates in $S_B$. High $\lambda_\text{pcsl}\gg1$ is necessary since raw $\mathcal{L}_{\text{PCSL}}$ is much smaller in magnitude than classification loss; normalization per initial batch statistics is recommended.

The effect on the embedding space is twofold: the manifold expands to provide distinct patient-specific regions (mitigating feature collapse driven solely by class labels), and the structure becomes multi-modal, reflecting mixed patient and disease characteristics.

## 6. Empirical Effects on the ICBHI Benchmark

The PAFA framework, incorporating PCSL and GPAL, demonstrated the following results on the ICBHI lung sound dataset:
- **Four-class (Normal/Crackle/Wheeze/Both):**
  - Baseline (BEATs+CE): 63.49%
  - PCSL+GPAL (full PAFA): 64.84% (absolute gain of +1.35%)
- **Two-class (Normal/Abnormal):**
  - Baseline: 70.76%
  - PAFA: 72.08% (absolute gain of +1.32%)
- **Ablation (BEATs backbone, four-class):**
  - w/o PCSL: 63.92%
  - w/o GPAL: 63.88%
  - full PAFA: 64.84%
  - *This suggests* PCSL alone provides an improvement of approximately 0.9–1.0% absolute.

t-SNE analyses reveal that standard CE-only training produces class-centric clusters, whereas the addition of PCSL (and GPAL) introduces prominent subclusters corresponding to patient idiosyncrasies—reduced intra-patient spread and increased centroid separation.

## 7. Practical Considerations and Limitations

Batch size must be configured to ensure multiple samples per patient for effective $\mu_p$ computation; if not, contributions to $S_W$ may degenerate. The computational expense of $S_B$ is quadratic in the number of patients in a batch but remains tractable under common batch size settings. Weighting $\lambda_\text{pcsl}$ is set high to align magnitudes of loss terms. By directly penalizing the ratio of within- versus between-patient dispersion, PCSL preserves individualized features for each patient and affords improved generalization to under-represented or outlier patients [2505.23834].

Source: https://www.emergentmind.com/topics/patient-cohesion-separation-loss-pcsl