wGmdh.jGmdh.oldskul
Class TwoInputModel

java.lang.Object
  extended by wGmdh.jGmdh.oldskul.Node
      extended by wGmdh.jGmdh.oldskul.Model
          extended by wGmdh.jGmdh.oldskul.TwoInputModel
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Node>
Direct Known Subclasses:
ErrorPropagatingModel

public class TwoInputModel
extends Model

Polynomial GMDH node with two inputs, by L2 fitting

See Also:
Serialized Form

Nested Class Summary
 class TwoInputModel.VisitedHt
          Uses a Hashtable to store pairs of Nodes and inputs for which they have calculated the output, to avoid multiple calculations of the same thing.
 
Nested classes/interfaces inherited from class wGmdh.jGmdh.oldskul.Model
Model.Summand
 
Nested classes/interfaces inherited from class wGmdh.jGmdh.oldskul.Node
Node.Visited
 
Field Summary
 TwoInputModel.VisitedHt visitinfo
           
 
Fields inherited from class wGmdh.jGmdh.oldskul.Model
coeffs, errorMeasure, links, sortedLinkIds, structureSelectionCriterion
 
Fields inherited from class wGmdh.jGmdh.oldskul.Node
graphics, trainSetOutput, validationSetOutput, visited
 
Constructor Summary
TwoInputModel(java.util.ArrayList<double[]> regressionGoal, Performance selectionCriterion, Performance errorMeasure, Node inputL, Node inputR)
           
TwoInputModel(double[] regressionGoals, Performance selectionCriterion, Performance errorMeasure, Node... links)
           
TwoInputModel(Node... links)
           
TwoInputModel(Performance selectionCriterion, Performance errorMeasure, Node... inputs)
          Sets up performance criteria and links.
 
Method Summary
protected  double[] coeffsFromData(double[] regressTo, double[][] trainingData)
          Least squares fitting of basic GMDH building-block, a (second-order) polynomial P(trainingData[0],trainingData[1]).
 double[] localOuputOnArray(double[][] inputs, double[] coefficients)
          Calculates the GMDH model output given an array of immediate inputs
protected  double localOutput(double[] inputs, double[] coefficients)
          Calculates this polynomial value given an array of immediate inputs
 double networkOutput(double[] inputs, int fold)
          Calculate total output of this GMDH model, recursively, given an instance.
 double networkOutputNoFlags(double[] inputs, int fold)
          Invoked by networkOutput.
 
Methods inherited from class wGmdh.jGmdh.oldskul.Model
coeffsAndErrors, coeffsAndErrors, coeffsAndErrors, collectTrainingData, collectValidationData, generateSummands, getCoeffs, getErrorMeasure, getErrorStructureLearningSet, getErrorStructureValidationSet, getSelectionCriterion, getStructureLearningGoals, getStructureLearningGoals, getStructureLearningInstances, getStructureLearningInstances, getStructureValidationGoals, getStructureValidationGoals, getStructureValidationInstances, getStructureValidationInstances, noLinks, setErrorMeasure, setSelectionCriterion
 
Methods inherited from class wGmdh.jGmdh.oldskul.Node
compareTo, getGlobalIdentifier, getIdentifier, getNrFolds, InitializeGraphics, setGlobalIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

visitinfo

public TwoInputModel.VisitedHt visitinfo
Constructor Detail

TwoInputModel

public TwoInputModel(Node... links)
Parameters:
links -

TwoInputModel

public TwoInputModel(java.util.ArrayList<double[]> regressionGoal,
                     Performance selectionCriterion,
                     Performance errorMeasure,
                     Node inputL,
                     Node inputR)
              throws TooBig,
                     ExpressionEqualToZero,
                     TooSmall
Parameters:
regressionGoal -
selectionCriterion -
errorMeasure -
inputL -
inputR -
Throws:
jGMDH.exceptions.TooBig
jGMDH.exceptions.ExpressionEqualToZero
jGMDH.exceptions.TooSmall
TooBig
ExpressionEqualToZero
TooSmall

TwoInputModel

public TwoInputModel(double[] regressionGoals,
                     Performance selectionCriterion,
                     Performance errorMeasure,
                     Node... links)
              throws TooBig,
                     ExpressionEqualToZero,
                     TooSmall
Parameters:
regressionGoals -
selectionCriterion -
errorMeasure -
links -
Throws:
jGMDH.exceptions.TooBig
jGMDH.exceptions.ExpressionEqualToZero
jGMDH.exceptions.TooSmall
TooBig
ExpressionEqualToZero
TooSmall

TwoInputModel

public TwoInputModel(Performance selectionCriterion,
                     Performance errorMeasure,
                     Node... inputs)
              throws TooBig,
                     ExpressionEqualToZero,
                     TooSmall
Sets up performance criteria and links. Does not determine coefficients and measure quality of fit.

Parameters:
selectionCriterion -
errorMeasure -
inputs -
Throws:
TooBig
ExpressionEqualToZero
TooSmall
Method Detail

coeffsFromData

protected double[] coeffsFromData(double[] regressTo,
                                  double[][] trainingData)
                           throws TooBig
Least squares fitting of basic GMDH building-block, a (second-order) polynomial P(trainingData[0],trainingData[1]). Coefficients of the polynomial are treated as unknowns.

Specified by:
coeffsFromData in class Model
Parameters:
regressTo - values we are fitting to
trainingData -
Returns:
coefficients of polynomial
Throws:
TooBig

localOuputOnArray

public double[] localOuputOnArray(double[][] inputs,
                                  double[] coefficients)
                           throws TooBig
Calculates the GMDH model output given an array of immediate inputs

Specified by:
localOuputOnArray in class Model
Parameters:
inputs - array of length of polynomial inputs (number of inputs is 2)
coefficients -
Returns:
coefficients[0] + coefficients[1] * inputs[0][i] + coefficients[2] * inputs[1][i] + coefficients[3] * inputs[0][i] * inputs[0][i] + coefficients[4] * inputs[0][i] * inputs[1][i] + coefficients[5] * inputs[1][i] * inputs[1][i];, where i ranges from 0 to trainingData[0].length-1 == x2.length-1
Throws:
TooBig

localOutput

protected double localOutput(double[] inputs,
                             double[] coefficients)
Calculates this polynomial value given an array of immediate inputs

Parameters:
inputs - array of two doubles, one for each input
coefficients -
Returns:
coefficients[0] + coefficients[1] * inputs[0] + coefficients[2] * inputs[1] + coefficients[3] * inputs[0] * inputs[0] + coefficients[4] * inputs[0] * inputs[1] + coefficients[5] * inputs[1] * inputs[1];

networkOutput

public double networkOutput(double[] inputs,
                            int fold)
Calculate total output of this GMDH model, recursively, given an instance. Note: Models that share the same layer can be have their outputs calculated in parallel. Procesing of an array of inputs can also be optimized. (Athough, Weka doesn't have a classifyInstance(Instance[]), only classifyInstance(Instance)).

Specified by:
networkOutput in class Node
Parameters:
inputs - instance data organized as an array
fold - index of fold. if there are no multiple folds, pass 0
Returns:

networkOutputNoFlags

public double networkOutputNoFlags(double[] inputs,
                                   int fold)
Invoked by networkOutput.

Specified by:
networkOutputNoFlags in class Node
Parameters:
inputs -
fold -
Returns: