Variable Dependency Graph¶
The Variable Dependency Graph widget builds a directed network whose nodes are variables and whose edges encode the dependencies declared in their expressions. Edge weights reflect the time-window size used by the expression, making it easy to spot which derived features have the widest temporal footprint.
The Variable Dependency Graph widget.¶
Inputs¶
Signal |
Type |
Description |
|---|---|---|
Variable Definitions |
|
A configuration table containing the |
Outputs¶
Signal |
Type |
Description |
|---|---|---|
Network |
|
A directed weighted graph. |
How It Works¶
The widget processes the input table row by row:
A row whose
Expressioncell is empty /NaN/?is treated as an original variable (source feature,var_type = Original).A row with a valid expression is treated as a derived variable (
var_type = Derived).
For every derived variable, the widget parses its expression and
collects the known variable names it uses as values. Every reference
produces one directed edge source → dependency (i.e. an edge
X1 → X2 means “X1’s expression references X2”). Names inside string
literals, names bound inside a comprehension or lambda, and the names
of called functions (sqrt, shift…) are not references. If an
expression cannot be parsed, its variable gets no edges and the widget
shows a warning naming it.
Edge Weights¶
Each edge carries a numeric weight that summarises how far back or forward in time the source variable looks at its dependency.
Rule¶
For an edge Xᵢ → Xⱼ:
If
Xⱼappears inside one or more temporal calls inXᵢ’s expression (shift,sum,mean,count,min,max,sd), the weight is the maximum absolute integer argument across all such calls. A temporal call counts only in the form the Time Features Constructor evaluates:shift(var, n)orf(var, n, m)with integer literals.If
Xⱼonly appears outside temporal calls (e.g.Xⱼ + 1), the weight defaults to1.
Examples¶
Expression on the source |
Edge weight |
Notes |
|---|---|---|
|
|
One temporal call, single argument. |
|
|
|
|
|
Plain reference, no temporal window. |
|
|
Mixed usage; the temporal occurrence wins. |
|
|
Maximum across all temporal calls. |
|
|
Per-dependency: edges |
Node Metadata¶
The output network exposes per-node metadata in network.nodes for
downstream styling:
Meta |
Type |
Values |
|---|---|---|
|
String |
Sanitised variable name (every non-alphanumeric character
becomes |
|
Discrete |
|
|
String |
The literal expression text for derived variables; empty for original ones. Pick it as Label in Network Explorer to see each derived node’s formula directly on the graph. |
Controls¶
Generate — rebuilds the graph from the current configuration table. The widget also auto-regenerates whenever a valid input arrives.
Warnings¶
Input has no derived variables; the dependency graph is empty. Fires when every row of the configuration table is an original variable (no
Expressionset). The output network has nodes but no edges. Usually means you forgot to attach the second output of Time Features Constructor instead of the data output.
Input Requirements¶
The first two columns of the input table must be named exactly
Variable and Expression. Any other shape is rejected with an
explicit error message; no network output is sent.
Usage Example¶
Connect the Variable Definitions output of Time Features Constructor to the input of this widget.
Connect the Network output to the Network Explorer widget from the Orange Network add-on.
In Network Explorer:
Color the nodes by
var_typeto separate derived from original features.Optionally map the edge thickness to the edge weights (the
dataarray of the sparse adjacency matrix) to visualise which dependencies span the widest temporal windows.
Implementation notes¶
Variable name lookup is O(1) via a precomputed
name → indexmap, so the full graph build is linear in the number of references.References and temporal calls are read from the expression’s syntax tree (
ast), reusing the constructor’sfreevars, soX1never matches insideX10or inside a string.Sanitisation reuses the Time Features Constructor’s
sanitized_name(plus NFKC normalisation, as Python applies to identifiers) so the names line up with how they are written inside expressions (temp (C)→temp__C_,1abc→_1abc).