2.48 Neural Network Fitting(Pro)

Summary

This Neural Network Fitting app is used to fit data with neural network backpropagation. It trains a neural network to map between a set of inputs and output. The app can be used to predict response of independent variables.

The app requires R software (minimum required version 3.4.1) and package neuralnet. The packages will be automatically installed when the App is launched the time. If not, please follow the steps of Installing the app section in this tutorial to trouble shoot.

Origin provides another app Neural Network Regression to do the same work with Python packages.

Sample OPJ

  1. Right click on the app in Apps Gallery and choose Show Samples Folder from the context menu
    NNR sample.png
  2. Drag and drop the project file in the opened folder to Origin to open it

Example 1: Two-Peaks Curve Fitting

We have a curve with two peaks, and want to fit it with network backpropagation. We will then predict Y values from given X values.

Two peaks.png

There is no fixed way for finding the best settings of the model. The settings often require several attempts based on your data, to optimize the results.

  1. Make sure we opened folder 1. Two Peaks
  2. Create a scatter plot graph from column A and B of Book5. Activate the graph and click on the Neural Network Fitting icon in the Apps Gallery to open the dialog
  3. Input is filled automatically with the 1st plot on graph
  4. In the Options tab, change the settings as below. and click OK button
    NNF Ex1 Options.png
    • "2 3 4 3" is the number of neurons in each hidden layer. (The selection of an architecture for your neural network can only be done by trial and error. You can refer to the reference page as a starting point.)
    • Hyperbolic Tangent is chosen as Activation Function because we are going to fit a nonlinear curve. Both Hyperbolic Tangent and Logistic are good for nonlinear curve with peaks.
    • Set K = 5 which means split the data sample into 5 groups for cross-validation. In cross-validation, each training data is treated as the test data, and is excluded from training data to judge which group it should be classified to, and then verify whether the classification is correct or not.
  5. A new book with Neural Network Regression result is generated
    NNF Ex1 Results.png
  6. Now we are going to predict Y from given X values. Click the green lock on the report sheet and choose Change Parameters from the menu.
  7. In the Prediction tab of the dialog, select Col(D) as Independent Variables and then click OK
    Nnr prediction.png
  8. We can find the predicted Y values in the sheet FitData
    NNF Ex1 Prediction.png

Example 2: Fisher's Iris Data

  1. Switch to folder 2.Fisher's Iris Data in the Project Explorer
  2. Activate the workbook in the folder, click on the Neural Network Fitting icon in the Apps Gallery to open the dialog
  3. In the Input tab, set Independent Data to be Column A ~ Column D, Dependent Data to be Column E
  4. In the Options tab, set settings as below. Then click OK to generate results
    NNF Ex2 Options.png
    • "4 3 2" is the number neurons in each hidden layer. We have three group in independent variable so it is good to have three hidden layers. (The selection of an architecture for your neural network can only be done by trial and error. You can refer to the reference page as a starting point.)
  5. In the Prediction tab, select Col(G)~Col(J) as Independent Variables and then click OK
    NNF Ex2 Prediction.png

Installing the APP

  1. Make sure you install R software (later than 3.4.1)
  2. Click the Neural Network Fitting icon NNF Icon.png on Apps Gallery
  3. The needed package will be downloaded automatically. If failed, The messages will be pop up in the results log
  4. Open the R package, copy and paste the last two lines from Results Log to R, press Enter to run them
  5. A dialog will be pop up for you to select a site, then the needed packages will be downloaded automatically in R
  6. Once the packages are successfully downloaded without error message , restart Origin