Class GraphClassificationTask<T>
- Namespace
- AiDotNet.Data.Structures
- Assembly
- AiDotNet.dll
Represents a graph classification task where the goal is to classify entire graphs.
public class GraphClassificationTask<T>
Type Parameters
TThe numeric type used for calculations, typically float or double.
- Inheritance
-
GraphClassificationTask<T>
- Inherited Members
Remarks
Graph classification assigns a label to an entire graph based on its structure and node/edge features. Unlike node classification (classify individual nodes) or link prediction (predict edges), graph classification treats the whole graph as a single data point.
For Beginners: Graph classification is like determining the category of a complex object.
Real-world examples:
Molecular Property Prediction:
- Input: Molecular graph (atoms as nodes, bonds as edges)
- Task: Predict molecular properties
- Examples:
- Is this molecule toxic?
- What is the solubility?
- Will this be a good drug candidate?
- Dataset: ZINC, QM9, BACE
Protein Function Prediction:
- Input: Protein structure graph
- Task: Predict protein function or family
- How: Analyze amino acid sequences and 3D structure
Chemical Reaction Prediction:
- Input: Reaction graph showing reactants and products
- Task: Predict reaction type or outcome
Social Network Analysis:
- Input: Community subgraphs
- Task: Classify community type or behavior
- Example: Identify bot networks vs organic communities
Code Analysis:
- Input: Abstract syntax tree (AST) or control flow graph
- Task: Detect bugs, classify code functionality
- Example: "Is this code snippet vulnerable to SQL injection?"
Key Challenge: Graph-level representation
- Must aggregate information from all nodes and edges
- Common approaches: Global pooling, hierarchical pooling, set2set
Properties
AvgNumEdges
Average number of edges per graph (for informational purposes).
public double AvgNumEdges { get; set; }
Property Value
AvgNumNodes
Average number of nodes per graph (for informational purposes).
public double AvgNumNodes { get; set; }
Property Value
IsMultiLabel
Whether this is a multi-label classification task.
public bool IsMultiLabel { get; set; }
Property Value
Remarks
- False: Each graph has exactly one label (e.g., molecule is toxic or not)
- True: Each graph can have multiple labels (e.g., molecule has multiple properties)
IsRegression
Whether this is a regression task instead of classification.
public bool IsRegression { get; set; }
Property Value
Remarks
For regression tasks (e.g., predicting molecular energy), labels are continuous values rather than discrete classes.
For Beginners: The difference between classification and regression: - **Classification**: Predict categories (e.g., "toxic" vs "non-toxic") - **Regression**: Predict continuous values (e.g., "solubility = 2.3 mg/L")
Examples:
- Classification: Is this molecule a good drug? (Yes/No)
- Regression: What is this molecule's binding affinity? (0.0 to 10.0)
NumClasses
Number of classes in the classification task.
public int NumClasses { get; set; }
Property Value
TestGraphs
List of test graphs.
public List<GraphData<T>> TestGraphs { get; set; }
Property Value
TestLabels
Labels for test graphs. Shape: [num_test_graphs] or [num_test_graphs, num_classes].
public Tensor<T> TestLabels { get; set; }
Property Value
- Tensor<T>
TrainGraphs
List of training graphs.
public List<GraphData<T>> TrainGraphs { get; set; }
Property Value
Remarks
Each graph in the list is an independent sample with its own structure and features.
TrainLabels
Labels for training graphs. Shape: [num_train_graphs] or [num_train_graphs, num_classes] for multi-label.
public Tensor<T> TrainLabels { get; set; }
Property Value
- Tensor<T>
ValGraphs
List of validation graphs.
public List<GraphData<T>> ValGraphs { get; set; }
Property Value
ValLabels
Labels for validation graphs. Shape: [num_val_graphs] or [num_val_graphs, num_classes].
public Tensor<T> ValLabels { get; set; }
Property Value
- Tensor<T>