pyCLINE 0.1.9__tar.gz → 0.1.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyCLINE
3
+ Version: 0.1.11
4
+ Summary: This package is the Python implementation of the CLINE method
5
+ Author-email: Bartosz Prokop <bartosz.prokop@kuleuven.be>, Nikita Frolov <nikita.frolov@kuleuven.be>, Lendert Gelens <lendert.gelens@kuleuven.be>
6
+ Project-URL: Homepage, https://pycline-ec8369.pages.gitlab.kuleuven.be/
7
+ Project-URL: Issues, https://gitlab.kuleuven.be/gelenslab/publications/pycline/-/issues
8
+ Keywords: model,model identification,nullcline,data-driven,machine learning,deep learning,torch,dynamics,oscillator,nonlinear dynamics,complex systems
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: matplotlib>=3.6.2
16
+ Requires-Dist: numpy<1.25.0,>=1.24.1
17
+ Requires-Dist: pandas~=1.5.2
18
+ Requires-Dist: torch>=2.4.1
19
+ Requires-Dist: tqdm>=4.66.1
20
+ Requires-Dist: jitcdde>=1.8.1
21
+ Requires-Dist: scipy>=1.9.3
22
+ Dynamic: license-file
23
+
24
+ # PyCLINE - python package for CLINE
25
+
26
+ The `pyCLINE` package is the python package based on the CLINE (**C**omputational **L**earning and **I**dentification of **N**ullclin**E**s).
27
+ It can be downloaded from PyPI with pip by using
28
+
29
+ pip install pyCLINE
30
+
31
+ The package allows to recreate all data, models and results shown in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), and to apply CLINE to other data sets.
32
+ In order to generate data used in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), a set of different models is being provided under `pyCLINE.model`.
33
+ Data from these models can be generated using `pyCLINE.generate_data()`.
34
+ For setting up the data prepartion and adjacent training a neural network, the submodule `pyCLINE.recovery_methods` is used.
35
+ The submodule contains the module for data_preparation `pyCLINE.recovery_methods.data_preparation` and for neural network training `pyCLINE.recovery_methods.nn_training`.
36
+
37
+ For a better understanding, `pyCLINE` also contains the module `pyCLINE.example` which provides four examples also found in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240) with step by step instructions on how to setup a CLINE pipeline.
38
+
39
+ Documentation of the package can be found hosted on [Gitlab pages](https://pycline-ec8369.pages.gitlab.kuleuven.be).
40
+
41
+ The structure of `pyCLINE` is shown here:
42
+ <!-- ![PyCLINE structure](pycline_structure.png) -->
43
+ <div style="text-align: center;">
44
+ <img src='pycline_structure.png' style="width: 70%;" />
45
+ </div>
46
+
47
+ # Example of use
48
+
49
+ As mentioned before, in order to run several examples, the module `example` can be called
50
+
51
+ ```python
52
+ import pyCLINE
53
+
54
+ pyCLINE.example(*example name*)
55
+ ```
56
+
57
+ where example names are `FHN` (FitzHugh-Nagumo model), `Bicubic` (Bicubic model), `GeneExpression` (Gene expression) or `DelayOscillator` (Delay oscillator model) which are introduced in the manuscript.
58
+
59
+ Additionally, below you can find the example for the use of the FitzHugh-Nagumo (FHN) model without the use of `pyCLINE.example`.
60
+ After installing the package, we import `pyCLINE` as well as `torch.nn` to be able to configure the activation function for the neural network training.
61
+ Additionally, we load `pandas` to be able to load generated test data sets.
62
+
63
+ ```python
64
+ import pyCLINE
65
+ import torch.nn as nn
66
+ import pandas
67
+ ```
68
+
69
+ Firstly, we start by generating the FHN data set, which we then can load as a Pandas Dataframe back into the file from the created data directory:
70
+
71
+ ```python
72
+ pyCLINE.generate_data.FHN(dt=0.1, N=1000000, epsilons=[0.3], n_intiaL_conditions=1)
73
+ df = pd.read_csv('data/synthetic/FHN_eps=0.3_a=0.0)
74
+ ```
75
+
76
+ This prepared Dataframe consists of many simulations from randomly selected initial conditions, but we just want to use a single one and reset the index of the dataframe.
77
+
78
+ ```python
79
+ df_sim = df[(df['sim']==1)].copy()
80
+ df_sim.reset_index(drop=True, inplace=True)
81
+ ```
82
+
83
+ This step can be skipped when using a single simulation with your data when you only have a single time series.
84
+ After this we can prepare the data for training, where we declare the column names with a set of parameters used to normalize the data:
85
+
86
+ ```python
87
+ df_sim, df_coef = pyCLINE.recovery_methods.data_preparation.prepare_data(df_sim, vars=['u', 'v'], time='time', tmin=10, scheme='derivative', value_min=0.0, value_max=1.0)
88
+ ```
89
+
90
+ We then can define the variables that will be used as input and output/target variables of the neural network, and split the datasets into training, test and validation:
91
+
92
+ ```python
93
+ input_train, target_train, input_test, target_test, input_val, target_val = pyCLINE.recovery_methods.data_preparation.shuffle_and_split(df_sim, input_vars = input_vars, target_var = target_vars, optimal_thresholding=False)
94
+ ```
95
+
96
+ With the prepared data, we can set up the model and train it:
97
+
98
+ ```python
99
+ #set up
100
+ nn_model, optimizer, loss_fn = recovery_methods.nn_training.configure_FFNN_model(Nin=len(input_vars), Nout=len(target_vars),Nlayers=3, Nnodes=64, summary=True, lr=1e-4, activation=nn.SiLU)
101
+
102
+ #training
103
+ training_loss, val_loss, test_loss, predictions_evolution, lc_predictions, _ = recovery_methods.nn_training.train_FFNN_model(model=nn_model, optimizer=optimizer, loss_fn=loss_fn, input_train=input_train,target_train=target_train,input_test=input_test, target_test=target_test, validation_data=(input_val, target_val), epochs=3000, batch_size=64, device='cpu',save_evolution=True,method='derivative', minimal_value=val_min,maximal_value=val_max)
104
+ ```
105
+
106
+ The result of the training are the losses and the predictions of the limit cycle (`lc_predictions`) and nullcline predictions (`predictions_evolution`) over the set amount of epochs, which can be used to visualize the outcome of the nullcline predictions.
107
+
108
+ # Contributing to pyCLINE
109
+
110
+ If you want to contribute to the `pyCLINE` package, you can do it so here on Gitlab by creating a feature either for bug reports or suggestions.
111
+
112
+ If you have already written code to fix bugs or add extensions then feel free to creat a pull request, however before putting substantial effort into major code changes please open an issue to discuss it.
@@ -0,0 +1,89 @@
1
+ # PyCLINE - python package for CLINE
2
+
3
+ The `pyCLINE` package is the python package based on the CLINE (**C**omputational **L**earning and **I**dentification of **N**ullclin**E**s).
4
+ It can be downloaded from PyPI with pip by using
5
+
6
+ pip install pyCLINE
7
+
8
+ The package allows to recreate all data, models and results shown in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), and to apply CLINE to other data sets.
9
+ In order to generate data used in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), a set of different models is being provided under `pyCLINE.model`.
10
+ Data from these models can be generated using `pyCLINE.generate_data()`.
11
+ For setting up the data prepartion and adjacent training a neural network, the submodule `pyCLINE.recovery_methods` is used.
12
+ The submodule contains the module for data_preparation `pyCLINE.recovery_methods.data_preparation` and for neural network training `pyCLINE.recovery_methods.nn_training`.
13
+
14
+ For a better understanding, `pyCLINE` also contains the module `pyCLINE.example` which provides four examples also found in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240) with step by step instructions on how to setup a CLINE pipeline.
15
+
16
+ Documentation of the package can be found hosted on [Gitlab pages](https://pycline-ec8369.pages.gitlab.kuleuven.be).
17
+
18
+ The structure of `pyCLINE` is shown here:
19
+ <!-- ![PyCLINE structure](pycline_structure.png) -->
20
+ <div style="text-align: center;">
21
+ <img src='pycline_structure.png' style="width: 70%;" />
22
+ </div>
23
+
24
+ # Example of use
25
+
26
+ As mentioned before, in order to run several examples, the module `example` can be called
27
+
28
+ ```python
29
+ import pyCLINE
30
+
31
+ pyCLINE.example(*example name*)
32
+ ```
33
+
34
+ where example names are `FHN` (FitzHugh-Nagumo model), `Bicubic` (Bicubic model), `GeneExpression` (Gene expression) or `DelayOscillator` (Delay oscillator model) which are introduced in the manuscript.
35
+
36
+ Additionally, below you can find the example for the use of the FitzHugh-Nagumo (FHN) model without the use of `pyCLINE.example`.
37
+ After installing the package, we import `pyCLINE` as well as `torch.nn` to be able to configure the activation function for the neural network training.
38
+ Additionally, we load `pandas` to be able to load generated test data sets.
39
+
40
+ ```python
41
+ import pyCLINE
42
+ import torch.nn as nn
43
+ import pandas
44
+ ```
45
+
46
+ Firstly, we start by generating the FHN data set, which we then can load as a Pandas Dataframe back into the file from the created data directory:
47
+
48
+ ```python
49
+ pyCLINE.generate_data.FHN(dt=0.1, N=1000000, epsilons=[0.3], n_intiaL_conditions=1)
50
+ df = pd.read_csv('data/synthetic/FHN_eps=0.3_a=0.0)
51
+ ```
52
+
53
+ This prepared Dataframe consists of many simulations from randomly selected initial conditions, but we just want to use a single one and reset the index of the dataframe.
54
+
55
+ ```python
56
+ df_sim = df[(df['sim']==1)].copy()
57
+ df_sim.reset_index(drop=True, inplace=True)
58
+ ```
59
+
60
+ This step can be skipped when using a single simulation with your data when you only have a single time series.
61
+ After this we can prepare the data for training, where we declare the column names with a set of parameters used to normalize the data:
62
+
63
+ ```python
64
+ df_sim, df_coef = pyCLINE.recovery_methods.data_preparation.prepare_data(df_sim, vars=['u', 'v'], time='time', tmin=10, scheme='derivative', value_min=0.0, value_max=1.0)
65
+ ```
66
+
67
+ We then can define the variables that will be used as input and output/target variables of the neural network, and split the datasets into training, test and validation:
68
+
69
+ ```python
70
+ input_train, target_train, input_test, target_test, input_val, target_val = pyCLINE.recovery_methods.data_preparation.shuffle_and_split(df_sim, input_vars = input_vars, target_var = target_vars, optimal_thresholding=False)
71
+ ```
72
+
73
+ With the prepared data, we can set up the model and train it:
74
+
75
+ ```python
76
+ #set up
77
+ nn_model, optimizer, loss_fn = recovery_methods.nn_training.configure_FFNN_model(Nin=len(input_vars), Nout=len(target_vars),Nlayers=3, Nnodes=64, summary=True, lr=1e-4, activation=nn.SiLU)
78
+
79
+ #training
80
+ training_loss, val_loss, test_loss, predictions_evolution, lc_predictions, _ = recovery_methods.nn_training.train_FFNN_model(model=nn_model, optimizer=optimizer, loss_fn=loss_fn, input_train=input_train,target_train=target_train,input_test=input_test, target_test=target_test, validation_data=(input_val, target_val), epochs=3000, batch_size=64, device='cpu',save_evolution=True,method='derivative', minimal_value=val_min,maximal_value=val_max)
81
+ ```
82
+
83
+ The result of the training are the losses and the predictions of the limit cycle (`lc_predictions`) and nullcline predictions (`predictions_evolution`) over the set amount of epochs, which can be used to visualize the outcome of the nullcline predictions.
84
+
85
+ # Contributing to pyCLINE
86
+
87
+ If you want to contribute to the `pyCLINE` package, you can do it so here on Gitlab by creating a feature either for bug reports or suggestions.
88
+
89
+ If you have already written code to fix bugs or add extensions then feel free to creat a pull request, however before putting substantial effort into major code changes please open an issue to discuss it.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyCLINE"
7
- version = "0.1.9"
7
+ version = "0.1.11"
8
8
  description = "This package is the Python implementation of the CLINE method"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -30,7 +30,7 @@ def example(example_model, plot):
30
30
  """
31
31
 
32
32
  #provide name of model to run example
33
- if example_model is None:
33
+ if example_model is None or example_model not in ['FHN', 'Bicubic', 'GeneExpression', 'DelayOscillator']:
34
34
  raise ValueError("Error: example_model is None: please provide a model name (FHN, Bicubic, GeneExpression, DelayOscillator).")
35
35
 
36
36
  # check if data already exists
@@ -115,7 +115,7 @@ def example(example_model, plot):
115
115
 
116
116
  # train the model
117
117
  print('Step 4: Train the model')
118
- training_loss, val_loss, test_loss, predictions_evolution, lc_predictions = recovery_methods.nn_training.train_FFNN_model(model=nn_model,
118
+ training_loss, val_loss, test_loss, predictions_evolution, lc_predictions, _ = recovery_methods.nn_training.train_FFNN_model(model=nn_model,
119
119
  optimizer=optimizer, loss_fn=loss_fn,
120
120
  input_train=input_train,
121
121
  target_train=target_train,input_test=input_test,
@@ -11,8 +11,6 @@ def FHN(dt=0.1, N=1000000, epsilons=[0.3], n_intiaL_conditions=1):
11
11
  N (int): Number of time steps. Defaults to 1000000.
12
12
  epsilons (list): List of time scale separations. Defaults to [0.3].
13
13
 
14
- Returns:
15
- None
16
14
  """
17
15
  if dt <= 0:
18
16
  raise ValueError("Time step (dt) must be positive.")
@@ -68,7 +68,7 @@ def init_weights(m):
68
68
  nn.init.zeros_(m.bias)
69
69
 
70
70
  def configure_FFNN_model(Nin, Nout, Nlayers, Nnodes, activation=nn.SiLU, optimizer_name='Adam', lr=1e-4,
71
- loss_fn=nn.MSELoss, summary=False):
71
+ loss_fn=nn.MSELoss, summary=False, load_state_dict=None):
72
72
  """
73
73
  Configure the Feedforward Neural Network (FFNN) model.
74
74
 
@@ -82,6 +82,7 @@ def configure_FFNN_model(Nin, Nout, Nlayers, Nnodes, activation=nn.SiLU, optimi
82
82
  lr (float, optional): Learning rate for training. Defaults to 1e-4.
83
83
  loss_fn (torch loss function module, optional): Loss function for training. Defaults to nn.MSELoss.
84
84
  summary (bool, optional): If model summary should be generated. Defaults to False.
85
+ load_state_dict (dict, optional): Load state dict for the model. Defaults to None. Can be string to a torch.state_dict path or a state_dict dictionary.
85
86
 
86
87
  Returns:
87
88
  model (torch model): setup FFNN model
@@ -118,6 +119,14 @@ def configure_FFNN_model(Nin, Nout, Nlayers, Nnodes, activation=nn.SiLU, optimi
118
119
  elif optimizer_name == 'Adadelta':
119
120
  optimizer = optim.Adadelta(model.parameters(), lr=lr)
120
121
 
122
+ if load_state_dict is not None:
123
+ if load_state_dict is str:
124
+ model.load_state_dict(torch.load(load_state_dict))
125
+ elif hasattr(load_state_dict, 'keys') and len(load_state_dict.keys())>0: # torch.nn.module.state_dict() has no dtype
126
+ model.load_state_dict(load_state_dict)
127
+ else:
128
+ raise NeuralNetworkSetupError('load_state_dict', load_state_dict, 'load_state_dict has to be str or dict.')
129
+
121
130
  loss_fn = loss_fn()
122
131
 
123
132
  if summary:
@@ -195,6 +204,7 @@ def train_FFNN_model(model, optimizer, loss_fn, input_train, target_train, input
195
204
  test_loss (float): testing loss
196
205
  predictions (list): predictions of nullcline structure over all epochs
197
206
  lc_predictions (list): limit cycle predictions over all epochs
207
+ model (torch model): trained FFNN model
198
208
  """
199
209
  #Error handling
200
210
  if input_train.shape[0] == 0:
@@ -359,7 +369,7 @@ def train_FFNN_model(model, optimizer, loss_fn, input_train, target_train, input
359
369
  test_loss /= len(test_loader.dataset)
360
370
  predictions_evolution=np.array(predictions)
361
371
  lc_predictions = np.array(lc_predictions)
362
- return train_losses, val_losses, test_loss, predictions_evolution, lc_predictions
372
+ return train_losses, val_losses, test_loss, predictions_evolution, lc_predictions, model
363
373
 
364
374
  def nullcline_prediction(model, Nsteps, device='cpu', method=None,min_val=0.0, max_val=1.0):
365
375
  """
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyCLINE
3
+ Version: 0.1.11
4
+ Summary: This package is the Python implementation of the CLINE method
5
+ Author-email: Bartosz Prokop <bartosz.prokop@kuleuven.be>, Nikita Frolov <nikita.frolov@kuleuven.be>, Lendert Gelens <lendert.gelens@kuleuven.be>
6
+ Project-URL: Homepage, https://pycline-ec8369.pages.gitlab.kuleuven.be/
7
+ Project-URL: Issues, https://gitlab.kuleuven.be/gelenslab/publications/pycline/-/issues
8
+ Keywords: model,model identification,nullcline,data-driven,machine learning,deep learning,torch,dynamics,oscillator,nonlinear dynamics,complex systems
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: matplotlib>=3.6.2
16
+ Requires-Dist: numpy<1.25.0,>=1.24.1
17
+ Requires-Dist: pandas~=1.5.2
18
+ Requires-Dist: torch>=2.4.1
19
+ Requires-Dist: tqdm>=4.66.1
20
+ Requires-Dist: jitcdde>=1.8.1
21
+ Requires-Dist: scipy>=1.9.3
22
+ Dynamic: license-file
23
+
24
+ # PyCLINE - python package for CLINE
25
+
26
+ The `pyCLINE` package is the python package based on the CLINE (**C**omputational **L**earning and **I**dentification of **N**ullclin**E**s).
27
+ It can be downloaded from PyPI with pip by using
28
+
29
+ pip install pyCLINE
30
+
31
+ The package allows to recreate all data, models and results shown in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), and to apply CLINE to other data sets.
32
+ In order to generate data used in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), a set of different models is being provided under `pyCLINE.model`.
33
+ Data from these models can be generated using `pyCLINE.generate_data()`.
34
+ For setting up the data prepartion and adjacent training a neural network, the submodule `pyCLINE.recovery_methods` is used.
35
+ The submodule contains the module for data_preparation `pyCLINE.recovery_methods.data_preparation` and for neural network training `pyCLINE.recovery_methods.nn_training`.
36
+
37
+ For a better understanding, `pyCLINE` also contains the module `pyCLINE.example` which provides four examples also found in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240) with step by step instructions on how to setup a CLINE pipeline.
38
+
39
+ Documentation of the package can be found hosted on [Gitlab pages](https://pycline-ec8369.pages.gitlab.kuleuven.be).
40
+
41
+ The structure of `pyCLINE` is shown here:
42
+ <!-- ![PyCLINE structure](pycline_structure.png) -->
43
+ <div style="text-align: center;">
44
+ <img src='pycline_structure.png' style="width: 70%;" />
45
+ </div>
46
+
47
+ # Example of use
48
+
49
+ As mentioned before, in order to run several examples, the module `example` can be called
50
+
51
+ ```python
52
+ import pyCLINE
53
+
54
+ pyCLINE.example(*example name*)
55
+ ```
56
+
57
+ where example names are `FHN` (FitzHugh-Nagumo model), `Bicubic` (Bicubic model), `GeneExpression` (Gene expression) or `DelayOscillator` (Delay oscillator model) which are introduced in the manuscript.
58
+
59
+ Additionally, below you can find the example for the use of the FitzHugh-Nagumo (FHN) model without the use of `pyCLINE.example`.
60
+ After installing the package, we import `pyCLINE` as well as `torch.nn` to be able to configure the activation function for the neural network training.
61
+ Additionally, we load `pandas` to be able to load generated test data sets.
62
+
63
+ ```python
64
+ import pyCLINE
65
+ import torch.nn as nn
66
+ import pandas
67
+ ```
68
+
69
+ Firstly, we start by generating the FHN data set, which we then can load as a Pandas Dataframe back into the file from the created data directory:
70
+
71
+ ```python
72
+ pyCLINE.generate_data.FHN(dt=0.1, N=1000000, epsilons=[0.3], n_intiaL_conditions=1)
73
+ df = pd.read_csv('data/synthetic/FHN_eps=0.3_a=0.0)
74
+ ```
75
+
76
+ This prepared Dataframe consists of many simulations from randomly selected initial conditions, but we just want to use a single one and reset the index of the dataframe.
77
+
78
+ ```python
79
+ df_sim = df[(df['sim']==1)].copy()
80
+ df_sim.reset_index(drop=True, inplace=True)
81
+ ```
82
+
83
+ This step can be skipped when using a single simulation with your data when you only have a single time series.
84
+ After this we can prepare the data for training, where we declare the column names with a set of parameters used to normalize the data:
85
+
86
+ ```python
87
+ df_sim, df_coef = pyCLINE.recovery_methods.data_preparation.prepare_data(df_sim, vars=['u', 'v'], time='time', tmin=10, scheme='derivative', value_min=0.0, value_max=1.0)
88
+ ```
89
+
90
+ We then can define the variables that will be used as input and output/target variables of the neural network, and split the datasets into training, test and validation:
91
+
92
+ ```python
93
+ input_train, target_train, input_test, target_test, input_val, target_val = pyCLINE.recovery_methods.data_preparation.shuffle_and_split(df_sim, input_vars = input_vars, target_var = target_vars, optimal_thresholding=False)
94
+ ```
95
+
96
+ With the prepared data, we can set up the model and train it:
97
+
98
+ ```python
99
+ #set up
100
+ nn_model, optimizer, loss_fn = recovery_methods.nn_training.configure_FFNN_model(Nin=len(input_vars), Nout=len(target_vars),Nlayers=3, Nnodes=64, summary=True, lr=1e-4, activation=nn.SiLU)
101
+
102
+ #training
103
+ training_loss, val_loss, test_loss, predictions_evolution, lc_predictions, _ = recovery_methods.nn_training.train_FFNN_model(model=nn_model, optimizer=optimizer, loss_fn=loss_fn, input_train=input_train,target_train=target_train,input_test=input_test, target_test=target_test, validation_data=(input_val, target_val), epochs=3000, batch_size=64, device='cpu',save_evolution=True,method='derivative', minimal_value=val_min,maximal_value=val_max)
104
+ ```
105
+
106
+ The result of the training are the losses and the predictions of the limit cycle (`lc_predictions`) and nullcline predictions (`predictions_evolution`) over the set amount of epochs, which can be used to visualize the outcome of the nullcline predictions.
107
+
108
+ # Contributing to pyCLINE
109
+
110
+ If you want to contribute to the `pyCLINE` package, you can do it so here on Gitlab by creating a feature either for bug reports or suggestions.
111
+
112
+ If you have already written code to fix bugs or add extensions then feel free to creat a pull request, however before putting substantial effort into major code changes please open an issue to discuss it.
@@ -14,5 +14,6 @@ src/pyCLINE/recovery_methods/__init__.py
14
14
  src/pyCLINE/recovery_methods/data_preparation.py
15
15
  src/pyCLINE/recovery_methods/nn_training.py
16
16
  tests/test_data_preparation.py
17
+ tests/test_example.py
17
18
  tests/test_generate_data.py
18
19
  tests/test_nn_training.py
@@ -24,7 +24,8 @@ class TestDataPreparation(unittest.TestCase):
24
24
  self.assertTrue('var2' in df_coef.columns)
25
25
 
26
26
  def test_prepare_data_invalid_input(self):
27
- # Test prepare_data function with invalid inputs
27
+ with self.assertRaises(ValueError):
28
+ prepare_data([], self.vars, self.time)
28
29
  with self.assertRaises(ValueError):
29
30
  prepare_data(self.df, 'var1', self.time)
30
31
  with self.assertRaises(ValueError):
@@ -43,6 +44,12 @@ class TestDataPreparation(unittest.TestCase):
43
44
  prepare_data(self.df, self.vars, self.time, value_max='invalid')
44
45
  with self.assertRaises(ValueError):
45
46
  prepare_data(self.df, self.vars, self.time, normalize='invalid')
47
+ with self.assertRaises(ValueError):
48
+ prepare_data(self.df, ['var1', 'varINVALID'], self.time)
49
+ with self.assertRaises(ValueError):
50
+ prepare_data(self.df, self.vars, 'invalid_time')
51
+ with self.assertRaises(ValueError):
52
+ prepare_data(self.df, self.vars, self.time, scheme='invalid')
46
53
 
47
54
  def test_shuffle_and_split(self):
48
55
  # Test shuffle_and_split function
@@ -58,6 +65,8 @@ class TestDataPreparation(unittest.TestCase):
58
65
 
59
66
  def test_shuffle_and_split_invalid_input(self):
60
67
  # Test shuffle_and_split function with invalid inputs
68
+ with self.assertRaises(ValueError):
69
+ shuffle_and_split([], self.vars, ['var1'])
61
70
  with self.assertRaises(ValueError):
62
71
  shuffle_and_split(self.df, 'var1', ['var1'])
63
72
  with self.assertRaises(ValueError):
@@ -74,6 +83,10 @@ class TestDataPreparation(unittest.TestCase):
74
83
  shuffle_and_split(self.df, self.vars, ['var1'], optimal_thresholding='invalid')
75
84
  with self.assertRaises(ValueError):
76
85
  shuffle_and_split(self.df, self.vars, ['var1'], plot_thresholding='invalid')
86
+ with self.assertRaises(ValueError):
87
+ shuffle_and_split(self.df, self.vars, ['varINVALID'])
88
+ with self.assertRaises(ValueError):
89
+ shuffle_and_split(self.df, ['varINVALID'] , ['var1'])
77
90
 
78
91
  if __name__ == '__main__':
79
92
  unittest.main()
@@ -0,0 +1,13 @@
1
+ import unittest
2
+ import torch
3
+ import pandas as pd
4
+ from pyCLINE import example
5
+
6
+ class TestExample(unittest.TestCase):
7
+ def test_example_run(self):
8
+ with self.assertRaises(ValueError):
9
+ example('')
10
+ with self.assertRaises(ValueError):
11
+ example('test')
12
+ with self.assertRaises(ValueError):
13
+ example(None)
@@ -78,34 +78,34 @@ class TestGenerateData(unittest.TestCase):
78
78
  data = pd.read_csv(path+fname)
79
79
  self.assertEqual(data.shape, (int(400/0.4),2))
80
80
 
81
- # def test_invalid_parameters(self):
82
- # # Test invalid parameters for FHN
83
- # with self.assertRaises(ValueError):
84
- # FHN(dt=-0.1, N=1000, epsilons=[0.3], n_intiaL_conditions=1)
85
- # with self.assertRaises(ValueError):
86
- # FHN(dt=0.1, N=-1000, epsilons=[0.3], n_intiaL_conditions=1)
87
- # with self.assertRaises(ValueError):
88
- # FHN(dt=0.1, N=1000, epsilons=[0.3], n_intiaL_conditions=0)
81
+ def test_invalid_parameters(self):
82
+ # Test invalid parameters for FHN
83
+ with self.assertRaises(ValueError):
84
+ FHN(dt=-0.1, N=1000, epsilons=[0.3], n_intiaL_conditions=1)
85
+ with self.assertRaises(ValueError):
86
+ FHN(dt=0.1, N=-1000, epsilons=[0.3], n_intiaL_conditions=1)
87
+ with self.assertRaises(ValueError):
88
+ FHN(dt=0.1, N=1000, epsilons=[0.3], n_intiaL_conditions=0)
89
89
 
90
- # # Test invalid parameters for Bicubic
91
- # with self.assertRaises(ValueError):
92
- # Bicubic(dt=-0.1, N=1000, n_intiaL_conditions=1)
93
- # with self.assertRaises(ValueError):
94
- # Bicubic(dt=0.1, N=-1000, n_intiaL_conditions=1)
95
- # with self.assertRaises(ValueError):
96
- # Bicubic(dt=0.1, N=1000, n_intiaL_conditions=0)
90
+ # Test invalid parameters for Bicubic
91
+ with self.assertRaises(ValueError):
92
+ Bicubic(dt=-0.1, N=1000, n_intiaL_conditions=1)
93
+ with self.assertRaises(ValueError):
94
+ Bicubic(dt=0.1, N=-1000, n_intiaL_conditions=1)
95
+ with self.assertRaises(ValueError):
96
+ Bicubic(dt=0.1, N=1000, n_intiaL_conditions=0)
97
97
 
98
- # # Test invalid parameters for GeneExpression
99
- # with self.assertRaises(ValueError):
100
- # GeneExpression(dt=-0.1, N=1000, n_intiaL_conditions=1)
101
- # with self.assertRaises(ValueError):
102
- # GeneExpression(dt=0.1, N=-1000, n_intiaL_conditions=1)
103
- # with self.assertRaises(ValueError):
104
- # GeneExpression(dt=0.1, N=1000, n_intiaL_conditions=0)
98
+ # Test invalid parameters for GeneExpression
99
+ with self.assertRaises(ValueError):
100
+ GeneExpression(dt=-0.1, N=1000, n_intiaL_conditions=1)
101
+ with self.assertRaises(ValueError):
102
+ GeneExpression(dt=0.1, N=-1000, n_intiaL_conditions=1)
103
+ with self.assertRaises(ValueError):
104
+ GeneExpression(dt=0.1, N=1000, n_intiaL_conditions=0)
105
105
 
106
- # # Test invalid parameters for DelayOscillator
107
- # with self.assertRaises(ValueError):
108
- # DelayOscillator(N=-1000)
106
+ # Test invalid parameters for DelayOscillator
107
+ with self.assertRaises(ValueError):
108
+ DelayOscillator(N=-1000)
109
109
 
110
110
  if __name__ == '__main__':
111
111
  unittest.main()
@@ -26,6 +26,9 @@ class TestNNTraining(unittest.TestCase):
26
26
  self.input_test = pd.DataFrame(torch.randn(20, self.Nin).numpy())
27
27
  self.target_test = pd.DataFrame(torch.randn(20, self.Nout).numpy())
28
28
  self.validation_data = (pd.DataFrame(torch.randn(20, self.Nin).numpy()), pd.DataFrame(torch.randn(20, self.Nout).numpy()))
29
+ model, _, _ = configure_FFNN_model(self.Nin, self.Nout, self.Nlayers, self.Nnodes, lr=self.lr, optimizer_name=self.optimizer_name, loss_fn=self.loss_fn)
30
+ self.state_dict = model.state_dict()
31
+
29
32
 
30
33
  def test_configure_FFNN_model_errors(self):
31
34
  with self.assertRaises(NeuralNetworkSetupError):
@@ -42,6 +45,12 @@ class TestNNTraining(unittest.TestCase):
42
45
  configure_FFNN_model(self.Nin, self.Nout, self.Nlayers, self.Nnodes, optimizer_name='')
43
46
  with self.assertRaises(NeuralNetworkSetupError):
44
47
  configure_FFNN_model(self.Nin, self.Nout, self.Nlayers, self.Nnodes, loss_fn=None)
48
+ with self.assertRaises(NeuralNetworkSetupError):
49
+ configure_FFNN_model(self.Nin, self.Nout, self.Nlayers, self.Nnodes, optimizer_name='Adam', loss_fn=self.loss_fn, load_state_dict=404)
50
+ with self.assertRaises(NeuralNetworkSetupError):
51
+ configure_FFNN_model(self.Nin, self.Nout, self.Nlayers, self.Nnodes, optimizer_name='Adam', loss_fn=self.loss_fn, load_state_dict=[])
52
+ with self.assertRaises(NeuralNetworkSetupError):
53
+ configure_FFNN_model(self.Nin, self.Nout, self.Nlayers, self.Nnodes, optimizer_name='Adam', loss_fn=self.loss_fn, load_state_dict={})
45
54
 
46
55
  def test_train_FFNN_model_data_errors(self):
47
56
  model, optimizer, loss_fn = configure_FFNN_model(self.Nin, self.Nout, self.Nlayers, self.Nnodes)
pycline-0.1.9/PKG-INFO DELETED
@@ -1,41 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pyCLINE
3
- Version: 0.1.9
4
- Summary: This package is the Python implementation of the CLINE method
5
- Author-email: Bartosz Prokop <bartosz.prokop@kuleuven.be>, Nikita Frolov <nikita.frolov@kuleuven.be>, Lendert Gelens <lendert.gelens@kuleuven.be>
6
- Project-URL: Homepage, https://pycline-ec8369.pages.gitlab.kuleuven.be/
7
- Project-URL: Issues, https://gitlab.kuleuven.be/gelenslab/publications/pycline/-/issues
8
- Keywords: model,model identification,nullcline,data-driven,machine learning,deep learning,torch,dynamics,oscillator,nonlinear dynamics,complex systems
9
- Classifier: Development Status :: 3 - Alpha
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.10
13
- Description-Content-Type: text/markdown
14
- License-File: LICENSE
15
- Requires-Dist: matplotlib>=3.6.2
16
- Requires-Dist: numpy<1.25.0,>=1.24.1
17
- Requires-Dist: pandas~=1.5.2
18
- Requires-Dist: torch>=2.4.1
19
- Requires-Dist: tqdm>=4.66.1
20
- Requires-Dist: jitcdde>=1.8.1
21
- Requires-Dist: scipy>=1.9.3
22
- Dynamic: license-file
23
-
24
- # PyCLINE - python package for CLINE
25
-
26
- The `pyCLINE` package is the python package based on the CLINE (**C**omputational **L**earning and **I**dentification of **N**ullclin**E**s).
27
- It can be downloaded from PyPI with pip by using
28
-
29
- pip install pyCLINE
30
-
31
- The package allows to recreate all data, models and results shown in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), and to apply CLINE to other data sets.
32
- In order to generate data used in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), a set of different models is being provided under `pyCLINE.model`.
33
- Data from these models can be generated using `pyCLINE.generate_data()`.
34
- For setting up the data prepartion and adjacent training a neural network, the submodule `pyCLINE.recovery_methods` is used.
35
- The submodule contains the module for data_preparation `pyCLINE.recovery_methods.data_preparation` and for neural network training `pyCLINE.recovery_methods.nn_training`.
36
-
37
- For a better understanding, `pyCLINE` also contains the module `pyCLINE.example` which provides four examples also found in XXX with step by step instructions on how to setup a CLINE pipeline.
38
-
39
- The structure of `pyCLINE` is shown here:
40
-
41
- ![PyCLINE structure](pycline_structure.png)
pycline-0.1.9/README.md DELETED
@@ -1,18 +0,0 @@
1
- # PyCLINE - python package for CLINE
2
-
3
- The `pyCLINE` package is the python package based on the CLINE (**C**omputational **L**earning and **I**dentification of **N**ullclin**E**s).
4
- It can be downloaded from PyPI with pip by using
5
-
6
- pip install pyCLINE
7
-
8
- The package allows to recreate all data, models and results shown in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), and to apply CLINE to other data sets.
9
- In order to generate data used in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), a set of different models is being provided under `pyCLINE.model`.
10
- Data from these models can be generated using `pyCLINE.generate_data()`.
11
- For setting up the data prepartion and adjacent training a neural network, the submodule `pyCLINE.recovery_methods` is used.
12
- The submodule contains the module for data_preparation `pyCLINE.recovery_methods.data_preparation` and for neural network training `pyCLINE.recovery_methods.nn_training`.
13
-
14
- For a better understanding, `pyCLINE` also contains the module `pyCLINE.example` which provides four examples also found in XXX with step by step instructions on how to setup a CLINE pipeline.
15
-
16
- The structure of `pyCLINE` is shown here:
17
-
18
- ![PyCLINE structure](pycline_structure.png)
@@ -1,41 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pyCLINE
3
- Version: 0.1.9
4
- Summary: This package is the Python implementation of the CLINE method
5
- Author-email: Bartosz Prokop <bartosz.prokop@kuleuven.be>, Nikita Frolov <nikita.frolov@kuleuven.be>, Lendert Gelens <lendert.gelens@kuleuven.be>
6
- Project-URL: Homepage, https://pycline-ec8369.pages.gitlab.kuleuven.be/
7
- Project-URL: Issues, https://gitlab.kuleuven.be/gelenslab/publications/pycline/-/issues
8
- Keywords: model,model identification,nullcline,data-driven,machine learning,deep learning,torch,dynamics,oscillator,nonlinear dynamics,complex systems
9
- Classifier: Development Status :: 3 - Alpha
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.10
13
- Description-Content-Type: text/markdown
14
- License-File: LICENSE
15
- Requires-Dist: matplotlib>=3.6.2
16
- Requires-Dist: numpy<1.25.0,>=1.24.1
17
- Requires-Dist: pandas~=1.5.2
18
- Requires-Dist: torch>=2.4.1
19
- Requires-Dist: tqdm>=4.66.1
20
- Requires-Dist: jitcdde>=1.8.1
21
- Requires-Dist: scipy>=1.9.3
22
- Dynamic: license-file
23
-
24
- # PyCLINE - python package for CLINE
25
-
26
- The `pyCLINE` package is the python package based on the CLINE (**C**omputational **L**earning and **I**dentification of **N**ullclin**E**s).
27
- It can be downloaded from PyPI with pip by using
28
-
29
- pip install pyCLINE
30
-
31
- The package allows to recreate all data, models and results shown in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), and to apply CLINE to other data sets.
32
- In order to generate data used in [Prokop, Billen, Frolov and Gelens (2025)](https://arxiv.org/abs/2503.16240), a set of different models is being provided under `pyCLINE.model`.
33
- Data from these models can be generated using `pyCLINE.generate_data()`.
34
- For setting up the data prepartion and adjacent training a neural network, the submodule `pyCLINE.recovery_methods` is used.
35
- The submodule contains the module for data_preparation `pyCLINE.recovery_methods.data_preparation` and for neural network training `pyCLINE.recovery_methods.nn_training`.
36
-
37
- For a better understanding, `pyCLINE` also contains the module `pyCLINE.example` which provides four examples also found in XXX with step by step instructions on how to setup a CLINE pipeline.
38
-
39
- The structure of `pyCLINE` is shown here:
40
-
41
- ![PyCLINE structure](pycline_structure.png)
File without changes
File without changes
File without changes