This repository contains:
- code for a method for fast network inference from time-series data
- code for producing the results and figures in "Network inference via process motifs" by Alice C Schwarze, Sara M. Ichinaga, and Bingni W. Brunton.
If you came here to get started on using LCCF and/or LCRC for network inference ASAP, here is a 3-step guide:
-
Install the package from Github via pip:
pip install git+https://github.com/acuschwarze/network-inference-via-process-motifs.git
-
Add the following code snippet to the files in which you want to use LCCF and/or LCRC.
import qspems
-
For a time-series data set
TS
given in the form of a 2d numpy array, you can now infer a network structure withm
edges a given number of edges in one line:A = qspems.inf_via_LCCF(TS, m)
or
A = qspems.inf_via_LCRC(TS, m)
The 2d numpy array A
is the adjacency matrix of the inferred directed, unweighted network. If you set num_edges
to None
, A
is a weighted score matrix.
You can add the keyword argument max_lag
to indicate if you expect any tranmission lags on edges. The default value max_lag=1
indicates that signals take exactly one time step to traverse an edge. Setting max_lag=2
indicates that you expect signals to traverse edges in either 1 or 2 steps. Larger values for max_lag
are also possible. However, very large numbers (e.g., max_lag=100
) may lead to long computation times.
-
qspems/qsPEMs.py
is the lite version of our code library. It lets a user compute the pairwise edge measures LCCF and LCRC and infer networks from them. (The non-lite version (i.e., all other files in this repository) includes functions for comparing LCCF and LCRC to other pairwise edge measures, running parameter sweeps, and plotting results.) -
notebooks-figures/
includes jupyter notebooks for recreating the figures in our paper. -
notebooks-other/
includes notebooks that we used to explore some aspects of the stochastic difference model and/or our proposed inference methods. Specifically, it includes a notebook where we derive the simplified expressions for the correction factors$\alpha^{(LCCF)}$ and$\alpha^{(LCRC)}$ . -
utils/
includes several function libraries that we have written to use in our notebooks. -
libs/
includes the function librarycurvygraph
from a previous research project (). We use it here to create drawings of process motifs. -
data/
includes pre-calculated synthetic data that make it easy to recreate the figures in our paper. To recalculate the data for any figure, changeload=True
toload=False
in the respective notebook before running it. To recalculate all data (which may take several days or weeks, depending on the available computing resources), delete all files indata/
before running the notebooks.
dill, matplotlib, networkx, netrd, numpy, scipy, seaborn,
curvygraph (included in libs)