Class Network

java.lang.Object
com.imsl.datamining.neural.Network
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
FeedForwardNetwork

public abstract class Network extends Object implements Serializable
Neural network base class.
See Also:
  • Constructor Details

    • Network

      public Network()
      Default constructor for Network. Since this class is abstract, it cannot be instantiated directly; this constructor is used by constructors in classes derived from Network.
  • Method Details

    • getNumberOfInputs

      public abstract int getNumberOfInputs()
      Returns the number of Network inputs.
      Returns:
      An int which contains the number of inputs.
    • getNumberOfOutputs

      public abstract int getNumberOfOutputs()
      Returns the number of Network output Perceptrons.
      Returns:
      An int which contains the number of outputs.
    • getInputLayer

      public abstract InputLayer getInputLayer()
      Returns the InputLayer object.
      Returns:
      The Network InputLayer.
    • createHiddenLayer

      public abstract HiddenLayer createHiddenLayer()
      Creates the next HiddenLayer in the Network.
      Returns:
      The new HiddenLayer.
    • getOutputLayer

      public abstract OutputLayer getOutputLayer()
      Returns the OutputLayer.
      Returns:
      The Network OutputLayer.
    • getPerceptrons

      public abstract Perceptron[] getPerceptrons()
      Returns an array containing the Perceptrons in the Network.
      Returns:
      An array of Perceptrons associated with this Network.
    • getLinks

      public abstract Link[] getLinks()
      Returns an array containing the Link objects in the Network.
      Returns:
      An array of Links associated with this Network.
    • getNumberOfLinks

      public abstract int getNumberOfLinks()
      Returns the number of Network Links among the nodes.
      Returns:
      An int which contains the number of Links in the Network.
    • getWeights

      public abstract double[] getWeights()
      Returns the weights.
      Returns:
      A double array containing the weights associated with Network Links.
    • setWeights

      public abstract void setWeights(double[] weights)
      Sets the weights.
      Parameters:
      weights - A double array which specifies the weights to be associated with Network Links.
    • getNumberOfWeights

      public abstract int getNumberOfWeights()
      Returns the number of weights in the Network.
      Returns:
      An int which contains the number of weights associated with this Network.
    • forecast

      public abstract double[] forecast(double[] x)
      Returns a forecast for each of the Network's outputs computed from the trained Network.
      Parameters:
      x - A double array of values with the same length and order as the training patterns used to train the Network.
      Returns:
      A double array containing the forecasts for the output Perceptrons. Its length is equal to the number of output Perceptrons.
    • getForecastGradient

      public abstract double[][] getForecastGradient(double[] x)
      Returns the derivatives of the outputs with respect to the weights.
      Parameters:
      x - A double array which specifies the input values at which the gradient is to be evaluated.
      Returns:
      A double array containing the gradient values. The value of gradient[i][j] is \(dy_i/dw_j\), where \(y_i\) is the i-th output and \(w_j\) is the j-th weight.
    • computeStatistics

      public double[] computeStatistics(double[][] xData, double[][] yData)
      Computes error statistics.

      This is a static method that can be used to compute the statistics regardless of the training class used to train the Network.

      Computes statistics related to the error. In this table, the observed values are \(y_i\). The forecasted values are \(\hat{y}_i\). The mean observed value is \( \bar{y} = \sum_i y_i / NC\), where N is the number of observations and C is the number of classes per observation.

      Index Name Formula
      0 SSE \(\frac{1}{2}\sum_i\left(y_i-\hat{y}_i\right)^2\)
      1 RMS \(\frac{\sum_i \left(y_i-\hat{y}_i\right)^2}{\sum_i \left(y_i-\bar{y}_i\right)} \)
      2 Laplacian \(\sum_i \left|y_i-\hat{y}_i\right|\)
      3 Scaled Laplacian \(\frac{\sum_i \left|y_i-\hat{y}_i\right|}{\sum_i\left|y_i-\bar{y}_i\right|}\)
      4 Max residual \(\max_i\left|y_i-\hat{y}_i\right|\)

      Parameters:
      xData - A double matrix containing the input values.
      yData - A double array containing the observed values.
      Returns:
      A double array containing the above described statistics.