All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.neural.NeuralNetwork

java.lang.Object
    |
    +----weka.classifiers.Classifier
            |
            +----weka.classifiers.DistributionClassifier
                    |
                    +----weka.classifiers.neural.NeuralNetwork

public class NeuralNetwork
extends DistributionClassifier
implements OptionHandler, WeightedInstancesHandler
A Classifier that uses backpropagation to classify instances. This network can be built by hand, created by an algorithm or both. The network can also be monitored and modified during training time. The nodes in this network are all sigmoid (except for when the class is numeric in which case the the output nodes become unthresholded linear units).

Version:
$Revision: 1.4.2.2 $
Author:
Malcolm Ware (mfw4@cs.waikato.ac.nz)

Constructor Index

 o NeuralNetwork()
The constructor.

Method Index

 o autoBuildTipText()
 
 o blocker(boolean)
A function used to stop the code that called buildclassifier from continuing on before the user has finished the decision tree.
 o buildClassifier(Instances)
Call this function to build and train a neural network for the training data provided.
 o decayTipText()
 
 o distributionForInstance(Instance)
Call this function to predict the class of an instance once a classification model has been built with the buildClassifier call.
 o getAutoBuild()
 
 o getDecay()
 
 o getGUI()
 
 o getHiddenLayers()
 
 o getLearningRate()
 
 o getMomentum()
 
 o getNominalToBinaryFilter()
 
 o getNormalizeAttributes()
 
 o getNormalizeNumericClass()
 
 o getOptions()
Gets the current settings of NeuralNet.
 o getRandomSeed()
 
 o getReset()
 
 o getTrainingTime()
 
 o getValidationSetSize()
 
 o getValidationThreshold()
 
 o globalInfo()
This will return a string describing the classifier.
 o GUITipText()
 
 o hiddenLayersTipText()
 
 o learningRateTipText()
 
 o listOptions()
Returns an enumeration describing the available options
 o main(String[])
Main method for testing this class.
 o momentumTipText()
 
 o nominalToBinaryFilterTipText()
 
 o normalizeAttributesTipText()
 
 o normalizeNumericClassTipText()
 
 o randomSeedTipText()
 
 o resetTipText()
 
 o setAutoBuild(boolean)
This will set whether the network is automatically built or if it is left up to the user.
 o setDecay(boolean)
 
 o setGUI(boolean)
This will set whether A GUI is brought up to allow interaction by the user with the neural network during training.
 o setHiddenLayers(String)
This will set what the hidden layers are made up of when auto build is enabled.
 o setLearningRate(double)
The learning rate can be set using this command.
 o setMomentum(double)
The momentum can be set using this command.
 o setNominalToBinaryFilter(boolean)
 
 o setNormalizeAttributes(boolean)
 
 o setNormalizeNumericClass(boolean)
 
 o setOptions(String[])
Parses a given list of options.
 o setRandomSeed(long)
This seeds the random number generator, that is used when a random number is needed for the network.
 o setReset(boolean)
This sets the network up to be able to reset itself with the current settings and the learning rate at half of what it is currently.
 o setTrainingTime(int)
Set the number of training epochs to perform.
 o setValidationSetSize(int)
This will set the size of the validation set.
 o setValidationThreshold(int)
This sets the threshold to use for when validation testing is being done.
 o toString()
 
 o trainingTimeTipText()
 
 o validationSetSizeTipText()
 
 o validationThresholdTipText()
 

Constructor Detail

 o NeuralNetwork
public NeuralNetwork()
          The constructor.

Method Detail

 o main
public static void main(java.lang.String argv[])
          Main method for testing this class.
Parameters:
argv - should contain command line options (see setOptions)
 o setDecay
public void setDecay(boolean d)
Parameters:
d - True if the learning rate should decay.
 o getDecay
public boolean getDecay()
Returns:
the flag for having the learning rate decay.
 o setReset
public void setReset(boolean r)
          This sets the network up to be able to reset itself with the current settings and the learning rate at half of what it is currently. This will only happen if the network creates NaN or infinite errors. Also this will continue to happen until the network is trained properly. The learning rate will also get set back to it's original value at the end of this. This can only be set to true if the GUI is not brought up.
Parameters:
r - True if the network should restart with it's current options and set the learning rate to half what it currently is.
 o getReset
public boolean getReset()
Returns:
The flag for reseting the network.
 o setNormalizeNumericClass
public void setNormalizeNumericClass(boolean c)
Parameters:
c - True if the class should be normalized (the class will only ever be normalized if it is numeric). (Normalization puts the range between -1 - 1).
 o getNormalizeNumericClass
public boolean getNormalizeNumericClass()
Returns:
The flag for normalizing a numeric class.
 o setNormalizeAttributes
public void setNormalizeAttributes(boolean a)
Parameters:
a - True if the attributes should be normalized (even nominal attributes will get normalized here) (range goes between -1 - 1).
 o getNormalizeAttributes
public boolean getNormalizeAttributes()
Returns:
The flag for normalizing attributes.
 o setNominalToBinaryFilter
public void setNominalToBinaryFilter(boolean f)
Parameters:
f - True if a nominalToBinary filter should be used on the data.
 o getNominalToBinaryFilter
public boolean getNominalToBinaryFilter()
Returns:
The flag for nominal to binary filter use.
 o setRandomSeed
public void setRandomSeed(long l)
          This seeds the random number generator, that is used when a random number is needed for the network.
Parameters:
l - The seed.
 o getRandomSeed
public long getRandomSeed()
Returns:
The seed for the random number generator.
 o setValidationThreshold
public void setValidationThreshold(int t)
          This sets the threshold to use for when validation testing is being done. It works by ending testing once the error on the validation set has consecutively increased a certain number of times.
Parameters:
t - The threshold to use for this.
 o getValidationThreshold
public int getValidationThreshold()
Returns:
The threshold used for validation testing.
 o setLearningRate
public void setLearningRate(double l)
          The learning rate can be set using this command. NOTE That this is a static variable so it affect all networks that are running. Must be greater than 0 and no more than 1.
Parameters:
l - The New learning rate.
 o getLearningRate
public double getLearningRate()
Returns:
The learning rate for the nodes.
 o setMomentum
public void setMomentum(double m)
          The momentum can be set using this command. THE same conditions apply to this as to the learning rate.
Parameters:
m - The new Momentum.
 o getMomentum
public double getMomentum()
Returns:
The momentum for the nodes.
 o setAutoBuild
public void setAutoBuild(boolean a)
          This will set whether the network is automatically built or if it is left up to the user. (there is nothing to stop a user from altering an autobuilt network however).
Parameters:
a - True if the network should be auto built.
 o getAutoBuild
public boolean getAutoBuild()
Returns:
The auto build state.
 o setHiddenLayers
public void setHiddenLayers(java.lang.String h)
          This will set what the hidden layers are made up of when auto build is enabled. Note to have no hidden units, just put a single 0, Any more 0's will indicate that the string is badly formed and make it unaccepted. Negative numbers, and floats will do the same. There are also some wildcards. These are 'a' = (number of attributes + number of classes) / 2, 'i' = number of attributes, 'o' = number of classes, and 't' = number of attributes + number of classes.
Parameters:
h - A string with a comma seperated list of numbers. Each number is the number of nodes to be on a hidden layer.
 o getHiddenLayers
public java.lang.String getHiddenLayers()
Returns:
A string representing the hidden layers, each number is the number of nodes on a hidden layer.
 o setGUI
public void setGUI(boolean a)
          This will set whether A GUI is brought up to allow interaction by the user with the neural network during training.
Parameters:
a - True if gui should be created.
 o getGUI
public boolean getGUI()
Returns:
The true if should show gui.
 o setValidationSetSize
public void setValidationSetSize(int a)
          This will set the size of the validation set.
Parameters:
a - The size of the validation set, as a percentage of the whole.
 o getValidationSetSize
public int getValidationSetSize()
Returns:
The percentage size of the validation set.
 o setTrainingTime
public void setTrainingTime(int n)
          Set the number of training epochs to perform. Must be greater than 0.
Parameters:
n - The number of epochs to train through.
 o getTrainingTime
public int getTrainingTime()
Returns:
The number of epochs to train through.
 o blocker
public void blocker(boolean tf)
          A function used to stop the code that called buildclassifier from continuing on before the user has finished the decision tree.
Parameters:
tf - True to stop the thread, False to release the thread that is waiting there (if one).
 o buildClassifier
public void buildClassifier(Instances i) throws java.lang.Exception
          Call this function to build and train a neural network for the training data provided.
Parameters:
i - The training data.
Throws:
Throws - exception if can't build classification properly.
Overrides:
buildClassifier in class Classifier
 o distributionForInstance
public double[] distributionForInstance(Instance i) throws java.lang.Exception
          Call this function to predict the class of an instance once a classification model has been built with the buildClassifier call.
Parameters:
i - The instance to classify.
Returns:
A double array filled with the probabilities of each class type.
Throws:
if - can't classify instance.
Overrides:
distributionForInstance in class DistributionClassifier
 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
Returns:
an enumeration of all the available options
 o setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
          Parses a given list of options. Valid options are:

-L num
Set the learning rate. (default 0.3)

-M num
Set the momentum (default 0.2)

-N num
Set the number of epochs to train through. (default 500)

-V num
Set the percentage size of the validation set from the training to use. (default 0 (no validation set is used, instead num of epochs is used)

-S num
Set the seed for the random number generator. (default 0)

-E num
Set the threshold for the number of consequetive errors allowed during validation testing. (default 20)

-G
Bring up a GUI for the neural net.

-A
Do not automatically create the connections in the net. (can only be used if -G is specified)

-B
Do Not automatically Preprocess the instances with a nominal to binary filter.

-H str
Set the number of nodes to be used on each layer. Each number represents its own layer and the num of nodes on that layer. Each number should be comma seperated. There are also the wildcards 'a', 'i', 'o', 't' (default 4)

-C
Do not automatically Normalize the class if it's numeric.

-I
Do not automatically Normalize the attributes.

-R
Do not allow the network to be automatically reset.

-D
Cause the learning rate to decay as training is done.

Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of NeuralNet.
Returns:
an array of strings suitable for passing to setOptions()
 o toString
public java.lang.String toString()
Returns:
string describing the model.
Overrides:
toString in class java.lang.Object
 o globalInfo
public java.lang.String globalInfo()
          This will return a string describing the classifier.
Returns:
The string.
 o learningRateTipText
public java.lang.String learningRateTipText()
Returns:
a string to describe the learning rate option.
 o momentumTipText
public java.lang.String momentumTipText()
Returns:
a string to describe the momentum option.
 o autoBuildTipText
public java.lang.String autoBuildTipText()
Returns:
a string to describe the AutoBuild option.
 o randomSeedTipText
public java.lang.String randomSeedTipText()
Returns:
a string to describe the random seed option.
 o validationThresholdTipText
public java.lang.String validationThresholdTipText()
Returns:
a string to describe the validation threshold option.
 o GUITipText
public java.lang.String GUITipText()
Returns:
a string to describe the GUI option.
 o validationSetSizeTipText
public java.lang.String validationSetSizeTipText()
Returns:
a string to describe the validation size option.
 o trainingTimeTipText
public java.lang.String trainingTimeTipText()
Returns:
a string to describe the learning rate option.
 o nominalToBinaryFilterTipText
public java.lang.String nominalToBinaryFilterTipText()
Returns:
a string to describe the nominal to binary option.
 o hiddenLayersTipText
public java.lang.String hiddenLayersTipText()
Returns:
a string to describe the hidden layers in the network.
 o normalizeNumericClassTipText
public java.lang.String normalizeNumericClassTipText()
Returns:
a string to describe the nominal to binary option.
 o normalizeAttributesTipText
public java.lang.String normalizeAttributesTipText()
Returns:
a string to describe the nominal to binary option.
 o resetTipText
public java.lang.String resetTipText()
Returns:
a string to describe the Reset option.
 o decayTipText
public java.lang.String decayTipText()
Returns:
a string to describe the Decay option.

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home