Module tgml.utils
Functions
split_vertices()
def split_vertices (graph: TigerGraph, timeout: int = 16000, **split_ratios) ‑> None
Split vertices into a different sets by a specified ratio. More precisely, it creates a boolean attribute with each attribute indicating whether the vertex is in the corresponding set.
For example, if you want to split the vertices into 80% train, 10% validation and 10% test, you can provide as arguments to the function train_mask=0.8
, val_mask=0.1
, test_mask=0.1
.
This will create 3 attributes train_mask
, val_mask
, test_mask
in the graph, if they don’t already exist.
80% of vertices will be set to train_mask=1
, 10% to val_mask=1
, and 10% to test_mask=1 at random. There will be no overlap between the partitions. You can name the attributes however you like as long as you follow the format, such as yesterday=0.8, today=0.1, tomorrow=0.1, but we recommend something meaningful.
Parameters
graph
: TigerGraph-
Connection to the TigerGraph database.
timeout
: int optional-
Timeout limit for the function call.
split_ratios
-
A list of attributes and ratios to split all vertices in the graph into. The ratios must add up to 1. For example, if you want to split the vertices into 80% training, 10% validation and 10% test, you can provide the following arguments
train_mask=0.8, val_mask=0.1, test_mask=0.1
. This will create 3 attributestrain_mask
,val_mask
,test_mask
in the graph, if they don’t already exist. 80% of vertices will be set totrain_mask=1
, 10% toval_mask=1
, and 10% totest_mask=1
at random. There will be no overlap between the partitions.