Contrastive Approach to Prior Free Positive Unlabeled Learning

Anish Acharya, Sujay Sanghavi · OpenReview

Abstract

Positive-Unlabeled (PU) learning is a critical challenge in machine learning where only a subset of positive examples and a large pool of unlabeled data are available. Traditional PU methods often suffer from high variance or rely heavily on an accurate estimate of the class prior, which is difficult to obtain in practice. We present a robust framework that leverages contrastive representation learning to address these issues. By introducing puCL, an unbiased and low-variance contrastive loss, and puPL, a geometry-aware pseudo-labeling algorithm, we demonstrate state-of-the-art performance across multiple benchmarks without requiring prior knowledge of the class distribution.

Introduction

In real-world applications such as medical diagnosis, fraud detection, and recommendation systems, confirmed negative labels are often scarce or non-existent. This setting, known as Positive-Unlabeled (PU) learning, requires models to distinguish between classes using only positive and unlabeled data.

The challenge is twofold. First, the Bias-Variance Trap: treating all unlabeled data as negatives introduces heavy bias, while purely self-supervised methods may lack the semantic guidance to separate classes effectively. Second, the Prior Problem: most existing PU methods require knowing the class prior ($\pi$)—the exact percentage of positives in the unlabeled pool. In practice, $\pi$ is incredibly hard to estimate accurately, and misspecification can lead to model collapse.

This paper introduces a framework that bridges the gap between self-supervised and supervised learning using contrastive techniques, providing an unbiased estimator that is stable even in low-supervision regimes.

Methodology

The proposed framework consists of three primary components designed to optimize feature representations and classification accuracy.

1. Positive Unlabeled Contrastive Learning (puCL)

The core innovation is puCL, a contrastive loss function that judiciously integrates labeled positives. It treats labeled positives as "anchors" that are attracted to other labeled positives in the batch. Meanwhile, unlabeled data is handled via standard self-supervision. Crucially, puCL avoids the bias of naive supervised contrastive learning by not assuming unlabeled samples are negatives. We prove that puCL is an unbiased estimator of the population contrastive loss, and its variance decreases monotonically as more labeled data is incorporated.

2. Prior-Aware Extension (puNCE)

When the class prior $\pi$ is available, the authors propose puNCE, a "soft" version of the loss. It treats each unlabeled sample as a probabilistic mixture of positive and negative classes, weighted by the prior. This method is surprisingly robust to moderate errors in the prior estimate, unlike traditional cost-sensitive methods that often fail if the prior is slightly off.

3. Geometry-Aware Pseudo-Labeling (puPL)

To convert learned embeddings into a classifier, the authors introduce puPL. Instead of training a classifier from scratch, puPL exploits the clusterable nature of the learned embedding space. It uses a modified k-means++ initialization where one cluster is anchored to the centroid of the labeled positives, effectively disambiguating the positive and negative clusters.

Experimental Evaluation

The framework was validated across a massive suite of benchmarks, including standard vision tasks (F-MNIST, CIFAR-10, STL-10), large-scale data (ImageNet-1k subsets), and domain-specific datasets like SVHN and Alzheimer’s Disease MRI scans. To test semantic robustness, the authors also created "CIFAR-hard" variants involving semantically similar classes like cats and dogs.

Key Results

  • Outperforming SOTA: The proposed framework consistently outperformed established baselines like nnPU, uPU, and Self-PU across all standard benchmarks.
  • Low-Supervision Success: In regimes where labeled positives are very scarce (e.g., 1,000 samples on CIFAR-I), the method achieved ~92-93% accuracy, significantly higher than traditional PU baselines.
  • Better Embeddings: t-SNE visualizations confirm that puCL and puNCE produce much tighter, more linearly separable clusters than standard self-supervised learning (ssCL).

Discussion and Conclusion

This work demonstrates that contrastive pre-training can do the "heavy lifting" by organizing data into clean, well-separated clusters. By focusing on the geometric organization of the feature space, the proposed puCL and puPL methods provide a stable and high-performing alternative to risk-minimization strategies. One of the most significant findings is that the framework remains highly competitive even when the class prior is completely unknown, removing a major bottleneck for real-world deployment. Future work may explore hybrid strategies that combine similarity and partition function corrections to further refine the contrastive loss.

Summary updated

BibTeX
@misc{acharya2024contrastive,
  author = {Anish Acharya and Sujay Sanghavi},
  title = {{Contrastive Approach to Prior Free Positive Unlabeled Learning}},
  year = {2024},
  eprint = {2402.06038},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.06038},
}
Figure