public class SparsePerceptron extends LinearThresholdUnit
Learner.labeler
is a single
discrete classifier that produces the same feature for every example object and that the values
that feature may take are available through the
Classifier.allowableValues()
method. The second
value returned from Classifier.allowableValues()
is treated as "positive", and it is assumed there are exactly 2 allowable values. Assertions will
produce error messages if these assumptions do not hold.
This algorithm's user-configurable parameters are stored in member fields of this class. They may
be set via either a constructor that names each parameter explicitly or a constructor that takes
an instance of Parameters
as input. The documentation in each member field in this class indicates the default
value of the associated parameter when using the former type of constructor. The documentation of
the associated member field in the
Parameters
class
indicates the default value of the parameter when using the latter type of constructor.
Modifier and Type | Class and Description |
---|---|
static class |
SparsePerceptron.Parameters
Simply a container for all of
SparsePerceptron 's configurable parameters. |
allowableValues, bias, defaultInitialWeight, defaultLearningRate, defaultThickness, defaultThreshold, defaultWeightVector, initialWeight, learningRate, negativeThickness, positiveThickness, threshold, weightVector
candidates, encoding, extractor, labeler, labelLexicon, lcFilePath, lexFilePath, lexicon, lossFlag, predictions, readLexiconOnDemand
containingPackage, name
Constructor and Description |
---|
SparsePerceptron()
The learning rate and threshold take default values, while the name of the classifier gets
the empty string.
|
SparsePerceptron(double r)
Sets the learning rate to the specified value, and the threshold takes the default, while the
name of the classifier gets the empty string.
|
SparsePerceptron(double r,
double t)
Sets the learning rate and threshold to the specified values, while the name of the
classifier gets the empty string.
|
SparsePerceptron(double r,
double t,
double pt)
Use this constructor to fit a thick separator, where both the positive and negative sides of
the hyperplane will be given the specified thickness, while the name of the classifier gets
the empty string.
|
SparsePerceptron(double r,
double t,
double pt,
double nt)
Use this constructor to fit a thick separator, where the positive and negative sides of the
hyperplane will be given the specified separate thicknesses, while the name of the classifier
gets the empty string.
|
SparsePerceptron(double r,
double t,
double pt,
double nt,
SparseWeightVector v)
Use this constructor to specify an alternative subclass of
SparseWeightVector , while
the name of the classifier gets the empty string. |
SparsePerceptron(SparsePerceptron.Parameters p)
Initializing constructor.
|
SparsePerceptron(String n)
The learning rate and threshold take default values.
|
SparsePerceptron(String n,
double r)
Sets the learning rate to the specified value, and the threshold takes the default.
|
SparsePerceptron(String n,
double r,
double t)
Sets the learning rate and threshold to the specified values.
|
SparsePerceptron(String n,
double r,
double t,
double pt)
Use this constructor to fit a thick separator, where both the positive and negative sides of
the hyperplane will be given the specified thickness.
|
SparsePerceptron(String n,
double r,
double t,
double pt,
double nt)
Use this constructor to fit a thick separator, where the positive and negative sides of the
hyperplane will be given the specified separate thicknesses.
|
SparsePerceptron(String n,
double r,
double t,
double pt,
double nt,
SparseWeightVector v)
Use this constructor to specify an alternative subclass of
SparseWeightVector . |
SparsePerceptron(String n,
SparsePerceptron.Parameters p)
Initializing constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
demote(int[] exampleFeatures,
double[] exampleValues,
double rate)
Scales the feature vector produced by the extractor by the learning rate and subtracts it
from the weight vector.
|
double |
getLearningRate()
Returns the current value of the
LinearThresholdUnit.learningRate variable. |
Learner.Parameters |
getParameters()
Retrieves the parameters that are set in this learner.
|
void |
promote(int[] exampleFeatures,
double[] exampleValues,
double rate)
Scales the feature vector produced by the extractor by the learning rate and adds it to the
weight vector.
|
void |
setLearningRate(double r)
Sets the
LinearThresholdUnit.learningRate member variable to the specified value. |
void |
write(PrintStream out)
Writes the algorithm's internal representation as text.
|
allowableValues, classify, clone, computeLearningRate, discreteValue, featureValue, forget, getAllowableValues, getBias, getInitialWeight, getNegativeThickness, getPositiveThickness, getThreshold, getWeightVector, initialize, learn, read, score, score, scores, setInitialWeight, setLabeler, setNegativeThickness, setParameters, setPositiveThickness, setThickness, setThreshold, shouldDemote, shouldPromote, write
classify, classify, classify, classify, countFeatures, createPrediction, createPrediction, demandLexicon, discreteValue, discreteValue, doneLearning, doneWithRound, emptyClone, featureValue, featureValue, getCurrentLexicon, getExampleArray, getExampleArray, getExtractor, getLabeler, getLabelLexicon, getLexicon, getLexiconDiscardCounts, getLexiconLocation, getModelLocation, getPrunedLexiconSize, learn, learn, learn, learn, read, readLabelLexicon, readLearner, readLearner, readLearner, readLearner, readLearner, readLearner, readLexicon, readLexicon, readLexiconOnDemand, readLexiconOnDemand, readModel, readModel, readParameters, realValue, realValue, realValue, save, saveLexicon, saveModel, scores, scores, scoresAugmented, setCandidates, setEncoding, setExtractor, setLabelLexicon, setLexicon, setLexiconLocation, setLexiconLocation, setLossFlag, setModelLocation, setModelLocation, setParameters, setReadLexiconOnDemand, unclone, unsetLossFlag, write, writeLexicon, writeModel, writeParameters
classify, discreteValueArray, getCompositeChildren, getInputType, getOutputType, realValueArray, test, toString, valueIndexOf
public SparsePerceptron()
public SparsePerceptron(double r)
r
- The desired learning rate value.public SparsePerceptron(double r, double t)
r
- The desired learning rate value.t
- The desired threshold value.public SparsePerceptron(double r, double t, double pt)
r
- The desired learning rate value.t
- The desired threshold value.pt
- The desired thickness.public SparsePerceptron(double r, double t, double pt, double nt)
r
- The desired learning rate value.t
- The desired threshold value.pt
- The desired positive thickness.nt
- The desired negative thickness.public SparsePerceptron(double r, double t, double pt, double nt, SparseWeightVector v)
SparseWeightVector
, while
the name of the classifier gets the empty string.r
- The desired learning rate value.t
- The desired threshold value.pt
- The desired positive thickness.nt
- The desired negative thickness.v
- An empty sparse weight vector.public SparsePerceptron(SparsePerceptron.Parameters p)
SparsePerceptron.Parameters
object.p
- The settings of all parameters.public SparsePerceptron(String n)
n
- The name of the classifier.public SparsePerceptron(String n, double r)
n
- The name of the classifier.r
- The desired learning rate value.public SparsePerceptron(String n, double r, double t)
n
- The name of the classifier.r
- The desired learning rate value.t
- The desired threshold value.public SparsePerceptron(String n, double r, double t, double pt)
n
- The name of the classifier.r
- The desired learning rate value.t
- The desired threshold value.pt
- The desired thickness.public SparsePerceptron(String n, double r, double t, double pt, double nt)
n
- The name of the classifier.r
- The desired learning rate value.t
- The desired threshold value.pt
- The desired positive thickness.nt
- The desired negative thickness.public SparsePerceptron(String n, double r, double t, double pt, double nt, SparseWeightVector v)
SparseWeightVector
.n
- The name of the classifier.r
- The desired learning rate value.t
- The desired threshold value.pt
- The desired positive thickness.nt
- The desired negative thickness.v
- An empty sparse weight vector.public SparsePerceptron(String n, SparsePerceptron.Parameters p)
SparsePerceptron.Parameters
object.n
- The name of the classifier.p
- The settings of all parameters.public Learner.Parameters getParameters()
getParameters
in class LinearThresholdUnit
public double getLearningRate()
LinearThresholdUnit.learningRate
variable.LinearThresholdUnit.learningRate
variable.public void setLearningRate(double r)
LinearThresholdUnit.learningRate
member variable to the specified value.r
- The new value for LinearThresholdUnit.learningRate
.public void promote(int[] exampleFeatures, double[] exampleValues, double rate)
promote
in class LinearThresholdUnit
exampleFeatures
- The example's array of feature indicesexampleValues
- The example's array of feature valuesrate
- The learning rate at which the weights are updated.public void demote(int[] exampleFeatures, double[] exampleValues, double rate)
demote
in class LinearThresholdUnit
exampleFeatures
- The example's array of feature indicesexampleValues
- The example's array of feature valuesrate
- The learning rate at which the weights are updated.public void write(PrintStream out)
LinearThresholdUnit.learningRate
,
LinearThresholdUnit.initialWeight
, LinearThresholdUnit.threshold
,
LinearThresholdUnit.positiveThickness
, LinearThresholdUnit.negativeThickness
,
and finally LinearThresholdUnit.bias
.Copyright © 2016. All rights reserved.