public class Perceptron extends AbstractClassifier implements AMRulesRegressorFunction
Modifier and Type | Field and Description |
---|---|
protected double |
accumulatedError |
FlagOption |
constantLearningRatioDecayOption |
protected double |
fadingFactor |
FloatOption |
fadingFactorOption |
protected boolean |
initialisePerceptron |
protected double |
learningRateDecay |
FloatOption |
learningRateDecayOption |
protected double |
learningRatio |
FloatOption |
learningRatioOption |
protected int[] |
numericAttributesIndex |
DoubleVector |
perceptronattributeStatistics |
protected double |
perceptronInstancesSeen |
protected double |
perceptronsumY |
protected double |
perceptronYSeen |
IntOption |
randomSeedOption |
DoubleVector |
squaredperceptronattributeStatistics |
protected double |
squaredperceptronsumY |
protected double[] |
weightAttribute |
classifierRandom, downSampleRatio, modelContext, randomSeed, trainingWeightSeenByModel
config
Constructor and Description |
---|
Perceptron() |
Perceptron(Perceptron p) |
Modifier and Type | Method and Description |
---|---|
double |
computeSD(double squaredVal,
double val,
double size) |
double |
getCurrentError() |
double |
getInstancesSeen() |
void |
getModelDescription(StringBuilder out,
int indent)
Returns a string representation of the model.
|
protected Measurement[] |
getModelMeasurementsImpl()
Gets the current measurements of this classifier.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. |
double[] |
getVotesForInstance(Instance inst)
Predicts the class memberships for a given instance.
|
double[] |
getWeights() |
boolean |
isRandomizable()
Gets whether this learner needs a random seed.
|
double[] |
normalizedInstance(Instance inst) |
double |
normalizedPrediction(Instance inst) |
void |
normalizeWeights() |
double |
prediction(double[] instanceValues) |
void |
reset() |
void |
resetError() |
void |
resetLearningImpl()
A method to reset the model
|
void |
setInstancesSeen(int pInstancesSeen) |
void |
setLearningRatio(double learningRatio) |
void |
setWeights(double[] w) |
void |
trainOnInstanceImpl(Instance inst)
Update the model using the provided instance
|
void |
updateWeights(Instance inst,
double learningRatio) |
contextIsCompatible, copy, correctlyClassifies, getAttributeNameString, getAWTRenderer, getClassLabelString, getClassNameString, getDescription, getDownSampleRatio, getModel, getModelContext, getModelMeasurements, getNominalValueString, getPredictionForInstance, getPredictionForInstance, getPurposeString, getSubClassifiers, getSublearners, getVotesForInstance, modelAttIndexToInstanceAttIndex, modelAttIndexToInstanceAttIndex, prepareForUseImpl, resetLearning, setModelContext, setRandomSeed, trainingHasStarted, trainingWeightSeenByModel, trainOnInstance, trainOnInstance, updateDownSampleRatio
getCLICreationString, getOptions, getPreparedClassOption, prepareClassOptions, prepareForUse, prepareForUse
copy, measureByteSize, measureByteSize, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getModel, getModelContext, getModelMeasurements, getPredictionForInstance, getSublearners, getVotesForInstance, resetLearning, setModelContext, setRandomSeed, trainingHasStarted, trainingWeightSeenByModel, trainOnInstance
copy, getCLICreationString, getOptions, getPurposeString, prepareForUse, prepareForUse
getDescription, measureByteSize
getAWTRenderer
public FlagOption constantLearningRatioDecayOption
public FloatOption learningRatioOption
public FloatOption learningRateDecayOption
public FloatOption fadingFactorOption
public IntOption randomSeedOption
protected double fadingFactor
protected double learningRatio
protected double learningRateDecay
protected double[] weightAttribute
public DoubleVector perceptronattributeStatistics
public DoubleVector squaredperceptronattributeStatistics
protected double perceptronInstancesSeen
protected double perceptronYSeen
protected double accumulatedError
protected boolean initialisePerceptron
protected double perceptronsumY
protected double squaredperceptronsumY
protected int[] numericAttributesIndex
public Perceptron()
public Perceptron(Perceptron p)
public void setWeights(double[] w)
public double[] getWeights()
public double getInstancesSeen()
public void setInstancesSeen(int pInstancesSeen)
public void resetLearningImpl()
resetLearningImpl
in class AbstractClassifier
public void reset()
public void resetError()
public void trainOnInstanceImpl(Instance inst)
trainOnInstanceImpl
in class AbstractClassifier
inst
- the instance to be used for trainingpublic double normalizedPrediction(Instance inst)
public double prediction(double[] instanceValues)
public double[] normalizedInstance(Instance inst)
public double computeSD(double squaredVal, double val, double size)
public void updateWeights(Instance inst, double learningRatio)
public void normalizeWeights()
public boolean isRandomizable()
Learner
isRandomizable
in interface Learner<Example<Instance>>
public double[] getVotesForInstance(Instance inst)
Classifier
getVotesForInstance
in interface Classifier
getVotesForInstance
in class AbstractClassifier
inst
- the instance to be classifiedprotected Measurement[] getModelMeasurementsImpl()
AbstractClassifier
getModelMeasurementsImpl
in class AbstractClassifier
public void getModelDescription(StringBuilder out, int indent)
AbstractClassifier
getModelDescription
in class AbstractClassifier
out
- the stringbuilder to add the descriptionindent
- the number of characters to indentpublic void setLearningRatio(double learningRatio)
public double getCurrentError()
getCurrentError
in interface AMRulesLearner
Copyright © 2019 University of Waikato, Hamilton, NZ. All Rights Reserved.