mrosol / Nonlincausality

Python package for Granger causality test with nonlinear forecasting methods.
MIT License
70 stars 13 forks source link

Error running example.py #3

Closed beejaya closed 1 year ago

beejaya commented 1 year ago

Hi, thanks for open sourcing this. I am trying to understand how to use your code by running the example.py but getting an error. Seems something is broken in the function definitions/usage. Please check.

TypeError Traceback (most recent call last) Cell In [68], line 41 38 data_train = data[:7000, :] 39 data_test = data[7000:, :] ---> 41 results = nlc.nonlincausalityMLP( 42 x=data_train, 43 maxlag=lags, 44 Dense_layers=2, 45 Dense_neurons=[100, 100], 46 x_test=data_test, 47 run=1, 48 add_Dropout=True, 49 Dropout_rate=0.01, 50 epochs_num=[50, 100], 51 learning_rate=[0.001, 0.0001], 52 batch_size_num=128, 53 verbose=True, 54 plot=True, 55 ) 57 #%% Example of obtaining the results 58 for lag in lags:

File ~/anaconda3/envs/nlctest/lib/python3.8/site-packages/nonlincausality/nonlincausality.py:817, in nonlincausalityMLP(x, maxlag, Dense_layers, Dense_neurons, x_test, run, z, z_test, add_Dropout, Dropout_rate, epochs_num, learning_rate, batch_size_num, verbose, plot) 743 def nonlincausalityMLP( 744 x, 745 maxlag, (...) 758 plot=False, 759 ): 760 """ 761 Parameters 762 ---------- (...) 815 816 """ --> 817 results = run_nonlincausality( 818 MLP_architecture, 819 x, 820 maxlag, 821 None, 822 None, 823 Dense_layers, 824 Dense_neurons, 825 x_test, 826 run, 827 z, 828 z_test, 829 add_Dropout, 830 Dropout_rate, 831 epochs_num, 832 learning_rate, 833 batch_size_num, 834 verbose, 835 plot, 836 "MLP", 837 ) 839 return results

TypeError: run_nonlincausality() missing 3 required positional arguments: 'verbose', 'plot', and 'functin_type'

mrosol commented 1 year ago

Hi, that issue is probably due to the recent changes in the code. You can try to use the nonlincausalityNN function instead.

beejaya commented 1 year ago

ok thanks for responding. Yesterday, I made some simple modifications to the code so that the positional arguments issue I encountered is taken care of. I am now able to run the example code across all the models.