<jupyter_start><jupyter_text>Demo for lsNGC  The following is a demo of a small toy example of a synthetic network. For now, lets assume that we have a causality algorithm, which we want to use for topology inference. We name it "$granger$", and we put it inside the following function:X: input timeseries data of order $T\times N$N=X.shape[0] number of variable $N$, and T=X.shape[1] number of time samples $T$Adj: Adjacency matrix of the multivariate input timeseries data<jupyter_code>import numpy as np
import scipy.io as sio
from scipy import stats
from utils import lsNGC as granger
import matplotlib.pyplot as plt
from scipy.io import loadmat
import networkx as nx
from recovery_performance import recovery_performance<jupyter_output><empty_output><jupyter_text>Synthetic benchmark, from our Nature paper<jupyter_code>benchmark_dataset=['logistic3']
benchmark_titles={'logistic3':'3-Fan In'}
benchmark_TS_set=np.array([50,100,200,500])
bechmark_algorithms=[]

algorithms_title={}
bechmark_algorithms_title=[algorithms_title[i] for i in bechmark_algorithms]

benchmark_label=dict()
AUC=dict()<jupyter_output><empty_output><jupyter_text>Logistic 3 dataset, according to our Nature paper- Has 50 networks of lengths up to 1000. - It has 3 nodes - Novel algorithm<jupyter_code>in_data_name='datasets/7SYNTHETICS/logistic_3.mat'


for TS in benchmark_TS_set:
    benchmark_label['logistic3']= [loadmat(in_data_name)['Adj'] for i in range(50)]
    ts_logistic=[loadmat(in_data_name)['pt_N'][i,:,-TS:] for i in range(50)]
    Adj_lsgc=[granger(ts_logistic[i], k_f=2, k_g=2, ar_order=1, normalize=1)[0] for i in range(50)]
    AUC['granger_logistic3_'+str(TS)]=recovery_performance(Adj_lsgc,benchmark_label['logistic3'])
    print("logistic3, auc lsgc for TS="+str(TS)+":", AUC['granger_logistic3_'+str(TS)].mean(),
          "+",AUC['granger_logistic3_'+str(TS)].std())<jupyter_output>logistic3, auc lsgc for TS=50: 1.0 + 0.0
logistic3, auc lsgc for TS=100: 1.0 + 0.0
logistic3, auc lsgc for TS=200: 1.0 + 0.0
logistic3, auc lsgc for TS=500: 1.0 + 0.0
{'fraction_non_alphanumeric': 0.11604095563139932, 'fraction_numerical': 0.03607996099463676, 'mean_word_length': 6.544117647058823, 'pattern_counts': {'":': 1, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '530554', 'license': 'MIT', 'n_tokens_mistral': 811, 'n_tokens_neox': 744, 'n_words': 203, 'path': 'Demo_lsNGC.ipynb', 'repo_name': 'Large-scale-causality-inference/Large-scale-nonlinear-causality', 'size': '2051'}