public class MultilayerPerceptron extends AbstractClassifier implements OptionHandler, WeightedInstancesHandler, Randomizable, IterativeClassifier
-L <learning rate> Learning Rate for the backpropagation algorithm. (Value should be between 0 - 1, Default = 0.3).
-M <momentum> Momentum Rate for the backpropagation algorithm. (Value should be between 0 - 1, Default = 0.2).
-N <number of epochs> Number of epochs to train through. (Default = 500).
-V <percentage size of validation set> Percentage size of validation set to use to terminate training (if this is non zero it can pre-empt num of epochs. (Value should be between 0 - 100, Default = 0).
-S <seed> The value used to seed the random number generator (Value should be >= 0 and and a long, Default = 0).
-E <threshold for number of consequetive errors> The consequetive number of errors allowed for validation testing before the netwrok terminates. (Value should be > 0, Default = 20).
-G GUI will be opened. (Use this to bring up a GUI).
-A Autocreation of the network connections will NOT be done. (This will be ignored if -G is NOT set)
-B A NominalToBinary filter will NOT automatically be used. (Set this to not use a NominalToBinary filter).
-H <comma seperated numbers for nodes on each layer> The hidden layers to be created for the network. (Value should be a list of comma separated Natural numbers or the letters 'a' = (attribs + classes) / 2, 'i' = attribs, 'o' = classes, 't' = attribs .+ classes) for wildcard values, Default = a).
-C Normalizing a numeric class will NOT be done. (Set this to not normalize the class if it's numeric).
-I Normalizing the attributes will NOT be done. (Set this to not normalize the attributes).
-R Reseting the network will NOT be allowed. (Set this to not allow the network to reset).
-D Learning rate decay will occur. (Set this to cause the learning rate to decay).
| Modifier and Type | Class and Description |
|---|---|
protected class |
MultilayerPerceptron.NeuralEnd
This inner class is used to connect the nodes in the network up to the data that they are
classifying, Note that objects of this class are only suitable to go on the attribute side or
class side of the network and not both.
|
| Modifier and Type | Field and Description |
|---|---|
protected double |
bestError |
protected double |
driftOff
Drift off counter
|
protected double |
lastRight
To keep track of error
|
protected int |
numInVal
The number of instances in the validation set (if any)
|
protected Instances |
originalFormatData
Data in original format (in case learning rate gets reset
|
protected double |
totalValWeight
Total weight of the instances in the validation set (if any)
|
protected double |
totalWeight
Total weight of the instances in the training set
|
protected Instances |
valSet
The instances in the validation set (if any)
|
BATCH_SIZE_DEFAULT, m_BatchSize, m_Debug, m_DoNotCheckCapabilities, m_numDecimalPlaces, NUM_DECIMAL_PLACES_DEFAULT| Constructor and Description |
|---|
MultilayerPerceptron()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
autoBuildTipText() |
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.
|
void |
buildClassifier(Instances i)
Call this function to build and train a neural network for the training data provided.
|
java.lang.String |
decayTipText() |
double[] |
distributionForInstance(Instance i)
Call this function to predict the class of an instance once a classification model has been built
with the buildClassifier call.
|
void |
done()
Signal end of iterating, useful for any house-keeping/cleanup
|
boolean |
getAutoBuild() |
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
boolean |
getDecay() |
boolean |
getGUI() |
java.lang.String |
getHiddenLayers() |
double |
getLearningRate() |
double |
getMomentum() |
boolean |
getNominalToBinaryFilter() |
boolean |
getNormalizeAttributes() |
boolean |
getNormalizeNumericClass() |
java.lang.String[] |
getOptions()
Gets the current settings of NeuralNet.
|
boolean |
getReset() |
java.lang.String |
getRevision()
Returns the revision string.
|
int |
getSeed()
Gets the seed for the random number generations
|
int |
getTrainingTime() |
int |
getValidationSetSize() |
int |
getValidationThreshold() |
java.lang.String |
globalInfo()
This will return a string describing the classifier.
|
java.lang.String |
GUITipText() |
java.lang.String |
hiddenLayersTipText() |
void |
initializeClassifier(Instances data)
Initializes an iterative classifier.
|
java.lang.String |
learningRateTipText() |
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(java.lang.String[] argv)
Main method for testing this class.
|
java.lang.String |
momentumTipText() |
boolean |
next()
Performs one iteration.
|
java.lang.String |
nominalToBinaryFilterTipText() |
java.lang.String |
normalizeAttributesTipText() |
java.lang.String |
normalizeNumericClassTipText() |
java.lang.String |
resetTipText() |
java.lang.String |
seedTipText() |
void |
setAutoBuild(boolean a)
This will set whether the network is automatically built or if it is left up to the user.
|
void |
setDecay(boolean d) |
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.
|
void |
setHiddenLayers(java.lang.String h)
This will set what the hidden layers are made up of when auto build is enabled.
|
void |
setLearningRate(double l)
The learning rate can be set using this command.
|
void |
setMomentum(double m)
The momentum can be set using this command.
|
void |
setNominalToBinaryFilter(boolean f) |
void |
setNormalizeAttributes(boolean a) |
void |
setNormalizeNumericClass(boolean c) |
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
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.
|
void |
setSeed(int l)
This seeds the random number generator, that is used when a random number is needed for the
network.
|
void |
setTrainingTime(int n)
Set the number of training epochs to perform.
|
void |
setValidationSetSize(int a)
This will set the size of the validation set.
|
void |
setValidationThreshold(int t)
This sets the threshold to use for when validation testing is being done.
|
java.lang.String |
toString() |
java.lang.String |
trainingTimeTipText() |
java.lang.String |
validationSetSizeTipText() |
java.lang.String |
validationThresholdTipText() |
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlacesclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclassifyInstanceprotected transient Instances valSet
protected transient int numInVal
protected transient double totalWeight
protected transient double totalValWeight
protected transient double driftOff
protected transient double lastRight
protected transient double bestError
protected transient Instances originalFormatData
public static void main(java.lang.String[] argv)
argv - should contain command line options (see setOptions)public void setDecay(boolean d)
d - True if the learning rate should decay.public boolean getDecay()
public void setReset(boolean r)
r - True if the network should restart with it's current options and set the learning rate
to half what it currently is.public boolean getReset()
public void setNormalizeNumericClass(boolean c)
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).public boolean getNormalizeNumericClass()
public void setNormalizeAttributes(boolean a)
a - True if the attributes should be normalized (even nominal attributes will get normalized
here) (range goes between -1 - 1).public boolean getNormalizeAttributes()
public void setNominalToBinaryFilter(boolean f)
f - True if a nominalToBinary filter should be used on the data.public boolean getNominalToBinaryFilter()
public void setSeed(int l)
setSeed in interface Randomizablel - The seed.public int getSeed()
RandomizablegetSeed in interface Randomizablepublic void setValidationThreshold(int t)
t - The threshold to use for this.public int getValidationThreshold()
public void setLearningRate(double l)
l - The New learning rate.public double getLearningRate()
public void setMomentum(double m)
m - The new Momentum.public double getMomentum()
public void setAutoBuild(boolean a)
a - True if the network should be auto built.public boolean getAutoBuild()
public void setHiddenLayers(java.lang.String h)
h - A string with a comma seperated list of numbers. Each number is the number of nodes to
be on a hidden layer.public java.lang.String getHiddenLayers()
public void setGUI(boolean a)
a - True if gui should be created.public boolean getGUI()
public void setValidationSetSize(int a)
a - The size of the validation set, as a percentage of the whole.public int getValidationSetSize()
public void setTrainingTime(int n)
n - The number of epochs to train through.public int getTrainingTime()
public void blocker(boolean tf)
tf - True to stop the thread, False to release the thread that is waiting there (if one).public Capabilities getCapabilities()
getCapabilities in interface ClassifiergetCapabilities in interface CapabilitiesHandlergetCapabilities in class AbstractClassifierCapabilitiespublic void initializeClassifier(Instances data) throws java.lang.Exception
initializeClassifier in interface IterativeClassifierdata - the instances to be used in inductionjava.lang.Exception - if the model cannot be initializedpublic boolean next()
throws java.lang.Exception
next in interface IterativeClassifierjava.lang.Exception - if this iteration fails for unexpected reasonspublic void done()
throws java.lang.Exception
done in interface IterativeClassifierjava.lang.Exception - if cleanup failspublic void buildClassifier(Instances i) throws java.lang.Exception
buildClassifier in interface Classifieri - The training data.java.lang.Exception - if can't build classification properly.public double[] distributionForInstance(Instance i) throws java.lang.Exception
distributionForInstance in interface ClassifierdistributionForInstance in class AbstractClassifieri - The instance to classify.java.lang.Exception - if can't classify instance.public java.util.Enumeration<Option> listOptions()
listOptions in interface OptionHandlerlistOptions in class AbstractClassifierpublic void setOptions(java.lang.String[] options)
throws java.lang.Exception
-L <learning rate> Learning Rate for the backpropagation algorithm. (Value should be between 0 - 1, Default = 0.3).
-M <momentum> Momentum Rate for the backpropagation algorithm. (Value should be between 0 - 1, Default = 0.2).
-N <number of epochs> Number of epochs to train through. (Default = 500).
-V <percentage size of validation set> Percentage size of validation set to use to terminate training (if this is non zero it can pre-empt num of epochs. (Value should be between 0 - 100, Default = 0).
-S <seed> The value used to seed the random number generator (Value should be >= 0 and and a long, Default = 0).
-E <threshold for number of consequetive errors> The consequetive number of errors allowed for validation testing before the netwrok terminates. (Value should be > 0, Default = 20).
-G GUI will be opened. (Use this to bring up a GUI).
-A Autocreation of the network connections will NOT be done. (This will be ignored if -G is NOT set)
-B A NominalToBinary filter will NOT automatically be used. (Set this to not use a NominalToBinary filter).
-H <comma seperated numbers for nodes on each layer> The hidden layers to be created for the network. (Value should be a list of comma separated Natural numbers or the letters 'a' = (attribs + classes) / 2, 'i' = attribs, 'o' = classes, 't' = attribs .+ classes) for wildcard values, Default = a).
-C Normalizing a numeric class will NOT be done. (Set this to not normalize the class if it's numeric).
-I Normalizing the attributes will NOT be done. (Set this to not normalize the attributes).
-R Reseting the network will NOT be allowed. (Set this to not allow the network to reset).
-D Learning rate decay will occur. (Set this to cause the learning rate to decay).
setOptions in interface OptionHandlersetOptions in class AbstractClassifieroptions - the list of options as an array of stringsjava.lang.Exception - if an option is not supportedpublic java.lang.String[] getOptions()
getOptions in interface OptionHandlergetOptions in class AbstractClassifierpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String globalInfo()
public java.lang.String learningRateTipText()
public java.lang.String momentumTipText()
public java.lang.String autoBuildTipText()
public java.lang.String seedTipText()
public java.lang.String validationThresholdTipText()
public java.lang.String GUITipText()
public java.lang.String validationSetSizeTipText()
public java.lang.String trainingTimeTipText()
public java.lang.String nominalToBinaryFilterTipText()
public java.lang.String hiddenLayersTipText()
public java.lang.String normalizeNumericClassTipText()
public java.lang.String normalizeAttributesTipText()
public java.lang.String resetTipText()
public java.lang.String decayTipText()
public java.lang.String getRevision()
getRevision in interface RevisionHandlergetRevision in class AbstractClassifier