How to create an output from trained model using "nnstart" with new set of input data with unknown output?

56 views (last 30 days)
Hello experts in MATLAB neural network. In nntool I introduce 3 files, "input", "target", and "sample". I use "input and target" to train my nn model. Then I use a completely new set of data (either larger or smaller number of data sets but with the same input variables) called "sample" and I extract my output called "predict" which I never given to nntool. How can I do the same with nnstart?

Answers (1)

Tejas
Tejas on 28 Mar 2024
Hello Ahmad,
To train a neural network and obtain predictions using the nnstart tool, simply type nnstart in the MATLAB command line. This action will launch the Neural Network Start GUI. Here is a step-by-step guide to navigate through the process:
  • First, select the type of neural network you wish to train.
  • At the top bar, choose the 'Import' option and add your input and target files.
  • Next, click on the 'Train' option in the top bar of the GUI. This will initiate the training of the model with your input data.
  • After the training is complete, click on the 'Export Model' option and then select 'Export to Workspace'.
  • You will be prompted to provide a name for the struct variable where this neural network will be saved. The default name is results.
  • The results will contain the network weights under the name Network and TrainingResults in the form of a structure.
  • To feed a sample dataset into this model, use the following syntax:
predict = results.Network(sample);
  • This will store the prediction in the 'predict' variable.
For additional details on the nnstart tool, please refer to this documentation:
Hope it helps!
  4 Comments
Ahmad Sedaghat
Ahmad Sedaghat on 1 Apr 2024 at 13:56
This is not Regression Learner. I am using nnstart. The menu do not give any Export. They only provide a function or a script. What version do you use?
Tejas
Tejas on 2 Apr 2024 at 6:53
I am currently working with MATLAB R2022b.
If the "Export to Workspace" option is missing, it may prove beneficial to reinstall or update MATLAB to newer versions for access to enhanced features and compatibility. This method simplifies the process, as selecting the "Export to Workspace" option immediately provides a structure into which the sample dataset can be input with minimal need for data conversion.
To obtain predictions from the function,save the function in a MATLAB file with the same name as the function itself. The following syntax can then be utilized: [Y, Xf, Af] = trainedModel(X, Xi, []);
This syntax is consistent with the code previously provided. To ensure the sample dataset is compatible with the model intended for predictions, appropriate conversion of the dataset is necessary. For guidance on this conversion, refer to the specific documentation for the desired neural network model. After inputting the dataset into the function, the variable "Y" will contain the predictions.

Sign in to comment.

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!