LinkPredictionTask<T>

Models & Types · AiDotNet.Data.Structures

Represents a link prediction task where the goal is to predict missing or future edges.

For Beginners

Link prediction is like recommending friendships or connections.

Real-world examples:

Social Networks:

  • Task: Friend recommendation
  • Question: “Will these two users become friends?”
  • How: Analyze mutual friends, shared interests, interaction patterns
  • Example: “You may know…” suggestions on Facebook/LinkedIn

E-commerce:

  • Task: Product recommendation
  • Question: “Will this user purchase this product?”
  • Graph: Users and products as nodes, purchases as edges
  • How: Users with similar purchase history likely buy similar products

Citation Networks:

  • Task: Predict future citations
  • Question: “Will paper A cite paper B?”
  • How: Analyze topic similarity, author connections, citation patterns

Drug Discovery:

  • Task: Predict drug-target interactions
  • Question: “Will this drug bind to this protein?”
  • Graph: Drugs and proteins as nodes, known interactions as edges

Key Techniques:

  • Negative sampling: Create non-existent edges as negative examples
  • Edge splitting: Hide some edges during training, predict them at test time
  • Node pair scoring: Learn to score how likely two nodes should connect

How It Works

Link prediction aims to predict whether an edge should exist between two nodes based on:

  • Node features
  • Graph structure
  • Edge patterns in the existing graph

Constructors

Constructor Summary
LinkPredictionTask()

Properties

Property Summary
GraphData<T> Graph { get; set; } The graph data with edges potentially removed for training.
Tensor<T> TestNegEdges { get; set; } Negative edge examples for testing.
Tensor<T> TestPosEdges { get; set; } Positive edge examples for testing.
Tensor<T> TrainNegEdges { get; set; } Negative edge examples (edges that don’t exist) for training.
Tensor<T> TrainPosEdges { get; set; } Positive edge examples (edges that exist) for training.
Tensor<T> ValNegEdges { get; set; } Negative edge examples for validation.
Tensor<T> ValPosEdges { get; set; } Positive edge examples for validation.
bool IsDirected { get; set; } Whether the graph is directed (default: false).
double NegativeSamplingRatio { get; set; } Ratio of negative to positive edges for sampling.