Data format¶
NetForge reads each dataset from a single directory:
The loader expects these files:
dataset_manifest.json may be present for your own notes or for example data, but the loader does not require it.
edges.csv¶
The edge table must contain:
u: source node idi: target node idts: snapshot index or timestamp
For weighted runs, the weight column you pass to --weight-col must also be present in edges.csv, unless you supply weights through --weight-npy.
Extra columns are fine. NetForge ignores them unless a command line flag points at them.
Example¶
u,i,ts,date,trade,distance_km
0,1,737409,2019-12-16,2,6.14
0,4,737409,2019-12-16,1,32.148
1,0,737409,2019-12-16,1,6.14
node_features.npy¶
node_features.npy must be a two-dimensional numeric array.
The indexing rule is strict:
- row
0stores features fornode_id == 0 - row
11stores features fornode_id == 11
If the dataset has N nodes, the matrix must have N rows. NetForge does not read padded node matrices.
With the default metadata settings, NetForge also reads num_farms, total_animals, the coordinate pair, and any count_ft_* columns from this matrix to build metadata tag nodes.
node_schema.json¶
The schema file records the feature order used by node_features.npy.
{
"node_feature_columns_in_order": [
"xco",
"yco",
"num_farms",
"total_animals"
],
"node_row_offset": 0
}
node_row_offset must be 0.
For geographic diagnostics, include either:
xcoandycocentroid_xandcentroid_y
node_map.csv¶
The node map must include:
node_idtype
You may also include labels, region codes, external ids, or any other metadata you want to keep next to the node ids.
Example¶
node_id,node_label,type,ubn,corop,corop_name
0,CR17_farm_1,Farm,TOYNL0000,CR17,Utrecht
1,CR17_farm_2,Farm,TOYNL0001,CR17,Utrecht
2,CR17_farm_3,Farm,TOYNL0002,CR17,Utrecht
The type column marks the partition role of each data node. Extra metadata columns can also be named in --metadata-fields so NetForge can turn them into metadata tag vertices.
Metadata tag layer¶
With the default fit settings, NetForge builds a joint data-metadata multilayer graph. It creates one metadata tag vertex per token and stores the data-to-tag edges in a layer named __metadata__.
The default metadata fields are:
coropnum_farms_bintotal_animals_bincentroid_gridft_tokens
Those tags come from these inputs:
coropreads fromnode_map.csvnum_farms_binandtotal_animals_binread from numeric columns innode_features.npycentroid_gridreads fromxcoandycoorcentroid_xandcentroid_yft_tokensreads from positivecount_ft_*columns innode_features.npy
Use --metadata-fields to choose a different set of metadata tags, --metadata-fields none to skip metadata tags while keeping the flag in the command, or --no-joint-metadata-model to fit the trade graph without the metadata layer.
Timestamps¶
The default timestamp format is ordinal days. If your edge table uses Unix time, pass:
--ts-format unix--ts-unit s,ms,us,ns, orD
You can slice the panel with:
--ts-startand--ts-end--date-startand--date-end
Build a new dataset safely¶
The bundled toy dataset is a good template. Before you create a larger dataset:
- Copy the four required files into a new dataset directory.
- Confirm that
node_features.npyhas one row per node id. - Check that
node_schema.jsonlists columns in the same order as the matrix. - Run
netforge fit --helpand choose the timestamp and weight flags that match your input table.