Building a Neural Network for Time Series Forecasting – Low-Code Workflow
The following post is from Yuchen Dong, Senior Financial Application Engineer at MathWorks.
Financial institutions forecast GDP to set capital buffers and plan stress-testing scenarios. Using MATLAB® Live Tasks and the Neural Net Time Series App, you can build and train a nonlinear autoregressive network in one line of code, without writing custom functions. This post shows how to import GDP data, clean missing values, and generate a trained model that forecasts for the next four quarters.
Step 1: Import Time Series Data with Live Task
First, open a new Live Script. From the Live Editor tab, click on Task and select Import Data.
Using this task, you can load GDP data directly from an Excel file:
MATLAB automatically identifies the structure as a timetable, where the first column is the date and the second column contains GDP values. Some entries have missing values.
Step 2: Clean Missing Data with Live Task
Next, insert the “Clean Missing Data” Live Task. This task allows us to handle missing entries with just a few clicks.
Select the GDP variable and choose linear interpolation to fill the missing values:
The output shows the original vs. filled-in values—blue for existing data and red for interpolated points.
Step 3: Build and Train the Neural Network
Once the data is preprocessed, run a single line of code to convert the numeric array to a cell array, which is required for the neural network app:
GDP = num2cell(newTable.GDP');
Then, launch the Neural Net Time Series App:
From there:
1. Select the Nonlinear Autoregressive (NAR) network, ideal for forecasting based on past values.
2. Import the GDP data.
3. Specify the data split for training (e.g., 90%), validation (5%), and testing (5%). Adjust the hidden layer size and time delay according to your model requirements.
4. Click Train to start the learning process:
5. The app provides performance metrics and visualizations:
o Response Plot: Shows training targets vs. predicted outputs, highlighting discrepancies such as those during economic shocks (e.g., recessions).
6. Automatically Generate Code
MATLAB allows automatic generation of the training script used in the modeling process:
Conclusion
This low-code workflow is ideal for quickly experimenting with time series models, especially if you’re new to neural networks or prefer visual tools. No custom code is needed to get meaningful insights from your data.
Want to try it yourself?
Open MATLAB, create a Live Script, and start exploring Live Tasks and the Neural Network Time Series App.
To request a Free Trial, click on the link below:
Try MATLAB, Simulink, and More…
Explore more resources:
Neural Net Time Series
Time series forecasting using Deep Learning
How to set up and manage experiments in MATLAB
How to do data cleaning in MATLAB
Low-code data analysis in MATLAB
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.