wGmdh.jGmdh.oldskul
Class Model

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

public abstract class Model
extends Node

Contains basic functionality of a GMDH model, such as connectivity information and obtaining data at the inputs. generateSummands and the Summand class are strictly related to the typical polynomial output function. If you want to customize the GMDH node (its output function or whatever), inherit from this class. TODO: Model could extend classifier directly? We could use Evaluation then and all related weka built-in functions

See Also:
Serialized Form

Nested Class Summary
 class Model.Summand
          Summand in the GMDH polynomial: coefficient*variable1*variable2*...
 
Nested classes/interfaces inherited from class wGmdh.jGmdh.oldskul.Node
Node.Visited
 
Field Summary
protected  java.util.ArrayList<double[]> coeffs
           
protected  Performance errorMeasure
           
 java.util.ArrayList<Node> links
           
protected  long[] sortedLinkIds
           
protected  Performance structureSelectionCriterion
           
 
Fields inherited from class wGmdh.jGmdh.oldskul.Node
graphics, trainSetOutput, validationSetOutput, visited
 
Constructor Summary
Model()
           
Model(java.util.ArrayList<double[]> regressionGoals, java.util.ArrayList<double[]> validationGoals, Performance selectionCriterion, Performance errorMeasure, java.util.ArrayList<Node> links)
          Deprecated. 
Model(java.util.ArrayList<double[]> regressionGoals, java.util.ArrayList<double[]> validationGoals, Performance selectionCriterion, Performance errorMeasure, Node... links)
          Deprecated. 
Model(java.util.ArrayList<Node> links)
           
Model(DatasetHandlerSupervised handler, Performance selectionCriterion, Performance errorMeasure, java.util.ArrayList<Node> links)
           
Model(double[] regressionGoals, Performance selectionCriterion, Performance errorMeasure, Node... links)
          Deprecated. 
Model(Node... links)
           
Model(Performance selectionCriterion, Performance errorMeasure, Node... links)
          No regression or model evaluation takes place in this constructor.
 
Method Summary
 void coeffsAndErrors(DatasetHandlerSupervised handler)
          Folds dataSetToFold.
 void coeffsAndErrors(weka.core.Instances dataset, double trainPercentage)
          Deprecated.  
 void coeffsAndErrors(weka.core.Instances datasetToFold, int numFolds)
          Deprecated. 
protected abstract  double[] coeffsFromData(double[] regressTo, double[][] trainingData)
          Obtains coefficients by regression.
 double[][] collectTrainingData(int fold)
          Deprecated. 
 double[][] collectValidationData(int fold)
          Deprecated. 
 java.util.ArrayList<Model.Summand> generateSummands(double[] coefficients)
          i.e. model has following form: P10 = a0 + a1*P1 + a2*P2 + a3*P3 + a4*P1*P1 + a5*P1*P2 + a6*P1*P3 + a7*P2*P2 + a8*P2*P3 + a9*P3*P3, method would return [ [a0, [null]], [a1,[P1]], [a2,[P2]], [a3,[P3]], [a4,[P1,P1]], [a5,[P1,P2]], ...]
 java.util.ArrayList<double[]> getCoeffs()
           
 Performance getErrorMeasure()
           
 double getErrorStructureLearningSet()
           
 double getErrorStructureValidationSet()
           
 Performance getSelectionCriterion()
           
 double[] getStructureLearningGoals(weka.core.Instances dataset, double trainPercentage)
          Deprecated. 
 double[] getStructureLearningGoals(weka.core.Instances dataset, int numfolds, int fold)
          Deprecated. 
 weka.core.Instances getStructureLearningInstances(weka.core.Instances dataset, double trainPercentage)
          Deprecated. 
 weka.core.Instances getStructureLearningInstances(weka.core.Instances dataset, int numfolds, int fold)
          Deprecated. 
 double[] getStructureValidationGoals(weka.core.Instances dataset, double trainPercentage)
          Deprecated. 
 double[] getStructureValidationGoals(weka.core.Instances dataset, int numfolds, int fold)
          Deprecated. 
 weka.core.Instances getStructureValidationInstances(weka.core.Instances dataset, double trainPercentage)
          Deprecated. 
 weka.core.Instances getStructureValidationInstances(weka.core.Instances dataset, int numfolds, int fold)
          Deprecated. 
abstract  double[] localOuputOnArray(double[][] inputs, double[] coeffs)
          Calculates value that a GMDH polynomial takes in a point, for an array of points, using coeffs as coefficients.
 boolean noLinks()
          Check if Model instance's links member is null
 void setErrorMeasure(Performance criterion)
           
 void setSelectionCriterion(Performance criterion)
           
 
Methods inherited from class wGmdh.jGmdh.oldskul.Node
compareTo, getGlobalIdentifier, getIdentifier, getNrFolds, InitializeGraphics, networkOutput, networkOutputNoFlags, setGlobalIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

links

public java.util.ArrayList<Node> links

coeffs

protected java.util.ArrayList<double[]> coeffs

sortedLinkIds

protected long[] sortedLinkIds

structureSelectionCriterion

protected Performance structureSelectionCriterion

errorMeasure

protected Performance errorMeasure
Constructor Detail

Model

public Model()

Model

public Model(Node... links)

Model

public Model(java.util.ArrayList<Node> links)

Model

@Deprecated
public Model(java.util.ArrayList<double[]> regressionGoals,
                        java.util.ArrayList<double[]> validationGoals,
                        Performance selectionCriterion,
                        Performance errorMeasure,
                        java.util.ArrayList<Node> links)
      throws TooBig,
             ExpressionEqualToZero,
             TooSmall
Deprecated. 

Parameters:
regressionGoals - each entry in the ArrayList coresponds to one fold
validationGoals -
selectionCriterion -
errorMeasure -
links -
Throws:
jGMDH.exceptions.TooBig
jGMDH.exceptions.ExpressionEqualToZero
jGMDH.exceptions.TooSmall
TooBig
ExpressionEqualToZero
TooSmall

Model

public Model(DatasetHandlerSupervised handler,
             Performance selectionCriterion,
             Performance errorMeasure,
             java.util.ArrayList<Node> links)
      throws TooBig,
             ExpressionEqualToZero,
             TooSmall
Parameters:
handler -
selectionCriterion -
errorMeasure -
links -
Throws:
TooBig
ExpressionEqualToZero
TooSmall

Model

@Deprecated
public Model(double[] regressionGoals,
                        Performance selectionCriterion,
                        Performance errorMeasure,
                        Node... links)
      throws TooBig,
             ExpressionEqualToZero,
             TooSmall
Deprecated. 

This constructor calculates only one set of coefficients from one set of regressors(it acts as if one fold only exists, instead of n-fold CV). Does not calculate how good the structure performs on some other dataset (validationSetOutput and errorStructureValidationSet). If needed, initialize Performance members and calculate performance after constructor call.

Parameters:
regressionGoals -
selectionCriterion -
errorMeasure -
links -
Throws:
jGMDH.exceptions.TooBig
jGMDH.exceptions.ExpressionEqualToZero
jGMDH.exceptions.TooSmall
TooBig
ExpressionEqualToZero
TooSmall

Model

@Deprecated
public Model(java.util.ArrayList<double[]> regressionGoals,
                        java.util.ArrayList<double[]> validationGoals,
                        Performance selectionCriterion,
                        Performance errorMeasure,
                        Node... links)
      throws TooBig,
             ExpressionEqualToZero,
             TooSmall
Deprecated. 

Parameters:
regressionGoals -
validationGoals -
selectionCriterion -
errorMeasure -
links -
Throws:
jGMDH.exceptions.TooBig
jGMDH.exceptions.ExpressionEqualToZero
jGMDH.exceptions.TooSmall
TooBig
ExpressionEqualToZero
TooSmall

Model

public Model(Performance selectionCriterion,
             Performance errorMeasure,
             Node... links)
      throws TooBig,
             ExpressionEqualToZero,
             TooSmall
No regression or model evaluation takes place in this constructor.

Parameters:
selectionCriterion -
errorMeasure -
links -
Throws:
jGMDH.exceptions.TooBig
jGMDH.exceptions.ExpressionEqualToZero
jGMDH.exceptions.TooSmall
TooBig
ExpressionEqualToZero
TooSmall
Method Detail

coeffsAndErrors

@Deprecated
public void coeffsAndErrors(weka.core.Instances datasetToFold,
                                       int numFolds)
                     throws TooBig,
                            TooSmall,
                            ExpressionEqualToZero
Deprecated. 

Folds dataSetToFold. For each fold it fits the model to find its coefficients and calculates average error

Parameters:
datasetToFold -
numFolds -
Throws:
TooBig
TooSmall
ExpressionEqualToZero

coeffsAndErrors

@Deprecated
public void coeffsAndErrors(weka.core.Instances dataset,
                                       double trainPercentage)
                     throws TooBig,
                            TooSmall,
                            ExpressionEqualToZero
Deprecated. 

Fits the model to find its coefficients and calculates its error on validation set

Parameters:
dataset -
trainPercentage -
Throws:
TooBig
TooSmall
ExpressionEqualToZero

coeffsAndErrors

public void coeffsAndErrors(DatasetHandlerSupervised handler)
                     throws TooBig,
                            TooSmall,
                            ExpressionEqualToZero
Folds dataSetToFold. For each fold it fits the model to find its coefficients and calculates average error

Parameters:
handler -
Throws:
TooBig
TooSmall
ExpressionEqualToZero

setSelectionCriterion

public void setSelectionCriterion(Performance criterion)

getSelectionCriterion

public Performance getSelectionCriterion()

setErrorMeasure

public void setErrorMeasure(Performance criterion)

getErrorMeasure

public Performance getErrorMeasure()

coeffsFromData

protected abstract double[] coeffsFromData(double[] regressTo,
                                           double[][] trainingData)
                                    throws TooBig,
                                           TooSmall,
                                           ExpressionEqualToZero
Obtains coefficients by regression.

Parameters:
regressTo - regression goal
trainingData - array of regressor values
Throws:
TooBig
TooSmall
ExpressionEqualToZero

localOuputOnArray

public abstract double[] localOuputOnArray(double[][] inputs,
                                           double[] coeffs)
                                    throws TooBig,
                                           TooSmall,
                                           ExpressionEqualToZero
Calculates value that a GMDH polynomial takes in a point, for an array of points, using coeffs as coefficients.

Parameters:
inputs - array of polynomial inputs
coeffs - coefficients
Throws:
TooBig
TooSmall
ExpressionEqualToZero

noLinks

public boolean noLinks()
Check if Model instance's links member is null

Returns:
yea or nay

collectTrainingData

@Deprecated
public double[][] collectTrainingData(int fold)
Deprecated. 

Collects output of fold-th fold from all Nodes this Model is linked to and stores it reorganized in matrix form, suitable for forming the system of linear equations for regressionGoal.

Parameters:
fold - fold index
Returns:

collectValidationData

@Deprecated
public double[][] collectValidationData(int fold)
Deprecated. 

Collects validationSetOutput of fold-th fold from all Nodes this Model is linked to and stores it reorganized in matrix form, suitable for forming the system of linear equations for regressionGoal.

Parameters:
fold - fold index
Returns:

generateSummands

public java.util.ArrayList<Model.Summand> generateSummands(double[] coefficients)
                                                    throws TooBig
i.e. model has following form: P10 = a0 + a1*P1 + a2*P2 + a3*P3 + a4*P1*P1 + a5*P1*P2 + a6*P1*P3 + a7*P2*P2 + a8*P2*P3 + a9*P3*P3, method would return [ [a0, [null]], [a1,[P1]], [a2,[P2]], [a3,[P3]], [a4,[P1,P1]], [a5,[P1,P2]], ...]

Parameters:
coefficients -
Returns:
Throws:
jGMDH.raw.exceptions.TooBig
TooBig

getErrorStructureLearningSet

public double getErrorStructureLearningSet()
Returns:
the errorStructureLearningSet

getErrorStructureValidationSet

public double getErrorStructureValidationSet()
Returns:
the errorStructureValidationSet

getCoeffs

public java.util.ArrayList<double[]> getCoeffs()
Returns:
the coeffs

getStructureValidationInstances

@Deprecated
public weka.core.Instances getStructureValidationInstances(weka.core.Instances dataset,
                                                                      int numfolds,
                                                                      int fold)
Deprecated. 


getStructureValidationGoals

@Deprecated
public double[] getStructureValidationGoals(weka.core.Instances dataset,
                                                       int numfolds,
                                                       int fold)
Deprecated. 


getStructureLearningInstances

@Deprecated
public weka.core.Instances getStructureLearningInstances(weka.core.Instances dataset,
                                                                    int numfolds,
                                                                    int fold)
Deprecated. 


getStructureLearningGoals

@Deprecated
public double[] getStructureLearningGoals(weka.core.Instances dataset,
                                                     int numfolds,
                                                     int fold)
Deprecated. 


getStructureValidationInstances

@Deprecated
public weka.core.Instances getStructureValidationInstances(weka.core.Instances dataset,
                                                                      double trainPercentage)
Deprecated. 


getStructureValidationGoals

@Deprecated
public double[] getStructureValidationGoals(weka.core.Instances dataset,
                                                       double trainPercentage)
Deprecated. 


getStructureLearningInstances

@Deprecated
public weka.core.Instances getStructureLearningInstances(weka.core.Instances dataset,
                                                                    double trainPercentage)
Deprecated. 


getStructureLearningGoals

@Deprecated
public double[] getStructureLearningGoals(weka.core.Instances dataset,
                                                     double trainPercentage)
Deprecated.