Tutorial: using NeurEco GUI on a Discrete Dynamic problem
Contents
Tutorial: using NeurEco GUI on a Discrete Dynamic problem#
The following section will use two test cases:
The test case Temperature forecasting.
The test case Nonlinear oscillator.
These test cases can be selected directly from the template window of the GUI:
Discrete Dynamic proposes various settings for the build and the evaluation. This tutorial is divided into two parts: Building a Discrete Dynamic model in the GUI and Evaluating a Discrete Dynamic model in the GUI.
Building a Discrete Dynamic model in the GUI#
There are two main options to build a Discrete Dynamic model:
with a validation percentage, the validation data is chosen from the training data by NeurEco
with validation data, the validation data is set manually.
For each option, the build can be done without selecting any of the advanced settings (steady state and hidden state, see Build parameters), or with these settings provided by the user.
Create an empty directory (TemperatureForecasting Example), extract the Temperature forecasting test case data there. The GUI automatically extracts the data and creates the project in the chosen directory. The created directory contains the following files:
The TemperetureForecasting directory is the one used by the GUI alongside the NumPy data files. The rest is used by the other NeurEco interfaces.
Note
To create the GUI project without using the template window, create a new directory called TemperatureForecasting and copy the data NumPy files into it. Go to the File menu, and click New, then choose the Dynamic solution and the Discrete Dynamic template. Choose the name of the project and the name of the model as: TemperatureForecasting and TemperatureForecasting and click ok.
The main window looks as follows at this stage:
Simple build without validation data#
To build a model without any of the advanced settings provided and without manually setting validation data:
Provide the Training data
Click the Build button in the GUI.
In this case NeurEco takes the last 30% of every provided trajectory in training data as validation data.
During the build NeurEco saves the intermediate modes to the checkpoint file. In term of performance, every new model in the checkpoint is an improvement of the previous one. Note that at the end of the build, the last model in the checkpoint corresponds to the final mode.
Any intermediate model can be used as if it was the final model: it can be evaluated on the new sets of data, exported, etc. Use the checkpoint slider to select a specific intermediate model. When an intermediate model is selected, the GUI updates the plot of reference vs prediction and the Sensitivity analysis plot (see Sensitivity analysis for Dynamic solution).
To perform a sensitivity analysis (see Sensitivity analysis for Dynamic solution) on any intermediate model:
Switch to the Metrics panel
Choose an intermediate model using the checkpoint slider
Choose a data set from Evaluation files (the testing data for this example)
Choose the initialization (see Sensitivity analysis for Dynamic solution)
Click on any output node in the Network sensitivity section (there is only one for Temperature forecasting test case)
The plot displays the sensitivity analysis graph as in figure below:
Simple build with validation data#
For the Temperature forecasting test case:
Create a new model in the TemperatureForecasting project by ether:
Creating from scratch: click on + in front of Models
Cloning setting of already existing model: right click on the model name and choose Clone
As before, set the first year data as Training Data
Set the second year data as Validation Data
Click the Build button
Note that although the 30% validation data is set, NeurEco will not take it into account because the Validation Data are provided.
As previously, any intermediate model can be used as if it was the final model: it can be evaluated on the new sets of data, exported, etc. Use the checkpoint slider to select a specific intermediate model. When an intermediate model is selected, the GUI updates the plot of reference vs prediction and the Sensitivity analysis plot (see Sensitivity analysis for Dynamic solution).
Advanced build#
This part uses Nonlinear oscillator. Create an empty directory (NonLinearOscillator Example), and extract the Nonlinear oscillator data there. The GUI will automatically extract the data and create the project in the chosen directory.
The main window looks as follows at this stage:
From the equation governing the outputs, one can see that a stationary state (see Advanced parameters) is described by the excitation set to \(0\) and thus the corresponding output to \(0\):
Set Advanced: steady input to \(0\)
Set Advanced: steady output to \(0\)
Note
The Discrete Dynamic model supports providing of only one steady state of the model.
The governing equation is of the second degree, which could imply that two hidden states (see Advanced parameters) are sufficient to describe the system. Here, one more hidden state is added to take the non linearity into account:
Set Advanced: max hidden states to \(3\)
To build the model:
Click on the Build button
The results on the training data:
Evaluating a Discrete Dynamic model in the GUI#
There are two options to evaluate a discrete dynamic model: with and without initial conditions (see. Evaluate NeurEco Discrete Dynamic model with GUI).
When using the GUI, evaluating the model without initial condition is straight forward:
Switch to the Evaluation panel
In Evaluating files section: select the data set on which to evaluate
Click the Evaluate button:
To provide an initial condition (recommended):
Switch to the Evaluation panel
In Evaluating files section: select the data set on which to evaluate
Click on Initialization interval: select button. A cursor appears on top of the plots, place the two ends of the cursor on the interval to select as initialization interval
Click the Evaluate button
Note
When providing the input and output files for evaluation, the output file is optional and in this case only the default evaluation is available. The output file can also contain less data points than the input file, for example, only the initialization interval with few time points.
The Metrics panel allows the user to extract a set of metrics about that dataset (see. Metrics for the Discrete Dynamic model with GUI). For the Discrete Dynamic template these metrics looks as shown in the figure below:
Exporting a Discrete dynamic model#
To export a Discrete Dynamic model:
Switch to the Export panel
(optional) Select an intermediate model to export. By default, the final model is selected.
Choose the export format: NeurEco .ernn format or FMU (requires embed license)
To create a Python script reproducing the main parts of the GUI project (see Export Discrete Dynamic from the GUI to the Python API):
Go to Python/Export NeurEco to Python in the menu bar of the GUI
Choose which parts of the project to export to a Python script
Select the destination where to save the script
Warning
To be able to use the script exported from the GUI, the NeurEco Python API package should be already installed on your computer.