advanced24 min studyLesson 828 in Engineering

Define what a negative edge means before sampling it

Control false negatives, information boundaries and candidate distributions in link prediction.

On this page

What you’ll understand

  • Distinguish an unobserved pair from a verified task-negative label.
  • Compute rejection cost and hidden-positive contamination under stated assumptions.
  • Keep supervision edges and future information out of prohibited message paths.

A graph usually records observed interactions rather than every relationship that does not exist. Negative-edge sampling creates a training or evaluation contrast by choosing pairs treated as negative under a particular task. That label requires a definition: absent at a cutoff, no event during a future horizon, or a sampled noninteraction under a benchmark protocol. These targets differ, and the sampler’s exclusions must respect the information allowed by each one.

Unobserved does not necessarily mean negative

A sampled pair can be a known positive accidentally retained by an approximate sampler, an unobserved true relation, or a pair that becomes positive during the target horizon. Those are different reasons a proposed negative may be inappropriate. Define candidate node types, self-pair rules, edge direction and prediction horizon first. A future interaction is not automatically a false negative for a task whose label is explicitly “no edge yet”; it is problematic when it contradicts the declared horizon label or asserted permanent absence.

For offline training, matured labels within the allowed training information boundary can legitimately define positive and negative outcomes. But filtering candidates using edges beyond that boundary can grant future knowledge. Keep label construction and feature availability separate: observing a future outcome for supervision does not permit its edge or derived features to appear in the earlier message graph. Treat censored horizons carefully when the observation period ends before a candidate’s full outcome window; missing follow-up is not reliable proof of a negative label.

P(known-positive draw)=kM,P(accepted)=1−kMP(\text{known-positive draw})=\frac{k}{M},\qquad P(\text{accepted})=1-\frac{k}{M}
The proposal is uniform over M eligible candidate pairs, of which k are known positives rejected by the sampler. Probabilities are dimensionless. This describes known-positive filtering, not the prevalence of unknown true positives.↔ Scroll wide equations horizontally.

Sampling probabilities define both cost and objective

With independent uniform proposals and rejection of those known positives, the expected proposals per accepted draw are the reciprocal of the acceptance probability. Dense neighborhoods can therefore make rejection expensive. An implementation can sample directly from a known complement, but constructing or maintaining that complement has its own cost. If proposals are nonuniform or sampling is without replacement, rederive the cost rather than importing the same geometric calculation. Report duplicate negative pairs and whether their multiplicities affect the loss.

Uniform random negatives can be much easier than plausible alternatives such as historically observed or semantically similar pairs. Changing the negative distribution changes the training contrast and evaluation candidate difficulty. The dynamic link-prediction evaluation literature explicitly demonstrates the importance of that protocol. If importance correction is needed for a declared target distribution, use the actual proposal probabilities and support; no weighting scheme recovers candidates that the proposal can never draw. A higher metric after making negatives easier is not evidence of a better graph model.

E[Tr]=r1−k/M,0≤k<M\mathbb E[T_r]=\frac{r}{1-k/M},\qquad 0\le k<M
T_r counts proposals needed for r accepted draws with independent replacement proposals and a fixed rejection set. It has units of proposal count and includes no additional rejection for duplicate candidates, type checks or unknown positives.↔ Scroll wide equations horizontally.

Prevent the target from becoming an input

PyTorch Geometric 2.7.0 LinkNeighborLoader warns that its approximate negative sampling can include false negatives and that supervision edges are not automatically masked out of message passing. Removing a target from a label list is therefore insufficient if the same edge remains in the sampled topology. For undirected relationships, also consider the reverse record; for repeated interactions, choose the correct time-specific exclusion. Preserve legitimate historical edges when the task allows them, while excluding the target information that would make the prediction circular.

For a contamination analogy, Reset the probability lab and set both p=0.2 and n=10. Predict two problematic draws on average and probability of none 0.8¹⁰≈0.1074. Play highlights exact binomial outcomes rather than sampling graph pairs. This assumes independent equal-probability contamination and does not inspect an adjacency structure, detect unknown positives or enforce supervision-edge masking. Its useful lesson is that even modest per-draw contamination can affect many minibatches; actual prevalence and dependence require evidence.

Filtering known positives does not certify the remaining pairs

A source has ten eligible candidate destinations. Three are known positives and are rejected from independent uniform replacement proposals. Request 100 accepted draws. For diagnosis only, suppose two of the seven remaining candidates are later verified positive for the specified label horizon.

  1. Known-positive rejection occurs with probability 3/10=0.3, leaving acceptance probability 0.7. These rates follow from the uniform proposal and fixed known-positive set, not from any learned scoring function.

  2. The expected number of proposals for 100 accepted draws is 100/0.7≈142.86. This includes repeats and ignores every other rejection condition; a without-replacement complement sampler would have a different accounting.

  3. Conditioned on acceptance, proposals are uniform over seven remaining candidates. The diagnostic hidden-positive fraction is therefore 2/7≈28.57%. Rejecting the three known positives has not turned those remaining pairs into verified negatives. Their later verification cannot be used outside the task’s allowed training-information boundary.

The result

Known-positive filtering has a measurable cost and a limited guarantee. Correct labels and a valid temporal information boundary still need their own construction and audit.

Explore the model

Interactive lab

Interactive lab · probability

Small contamination rates affect batches

Reset → set p=0.2 and n=10 → predict mean 2 and P(K=0)=0.1073741824. Playback highlights exact outcomes rather than drawing negative graph edges.

Small contamination rates affect batchesThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forThe iid binomial model assumes a fixed contamination probability. It does not identify false negatives or mask target edges.

Check your understanding

What is the safest conclusion after rejecting every known positive from a candidate set?

Try it yourself

There are eight candidate destinations, two known positives, and independent uniform replacement proposals. Find the expected proposals for three accepted draws. If one remaining candidate is later verified positive for the target horizon, what is the accepted-draw contamination fraction?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Acceptance is six out of eight. After rejection the accepted draws are uniform over the remaining six, under this specific proposal scheme.

Compare with the solution

Expected proposals are 3/(6/8)=4. The diagnostic contamination fraction is 1/6≈16.67%. This later verification describes a label issue under the specified horizon; it cannot justify injecting forbidden future information into earlier training inputs or candidate selection. Additional duplicate rejection would change the proposal-count calculation.

Take it with you

  • A task-negative label requires more than an absent observed edge.
  • Negative distributions determine rejection cost and candidate difficulty.
  • Supervision-edge masking and temporal visibility need explicit checks.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.