public class MuxLearner extends Learner
MuxLearner
uses one of many Learner
s indexed by the first feature in
an example to produce a classification. During training, the features produced by the first child
classifier of this classifier's composite generator feature extractor are taken to determine
which Learner
s will learn from the training object. For any given example, there
must be one Feature
produced by the labeler for each Feature
produced
by the first child classifier. If this classifier's feature extractor is not a composite
generator, the first feature it produces is the only one taken.
It is assumed that the Learner
being multiplexed expects a single label feature on
each training example, and that the feature(s) used to do the multiplexing are
DiscreteFeature
(s). Furthermore, if this classifier's feature extractor is a
composite generator, it must produce the same number of features as this classifier's labeler,
and they must correspond to each other in the order produced.
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 |
MuxLearner.Parameters
Simply a container for all of
MuxLearner 's configurable parameters. |
Modifier and Type | Field and Description |
---|---|
protected Learner |
baseLearner
Instances of this learning algorithm will be multiplexed; default
null . |
static Learner |
defaultBaseLearner
Default for
baseLearner . |
static String |
defaultDefaultPrediction
Default for
defaultPrediction . |
protected Feature |
defaultFeature
A feature whose value is
defaultPrediction . |
protected String |
defaultPrediction
This string is returned during testing when the multiplexed
Learner doesn't
exist; default defaultDefaultPrediction . |
protected edu.illinois.cs.cogcomp.core.datastructures.vectors.OVector |
network
A map from feature values to learners.
|
candidates, encoding, extractor, labeler, labelLexicon, lcFilePath, lexFilePath, lexicon, lossFlag, predictions, readLexiconOnDemand
containingPackage, name
Constructor and Description |
---|
MuxLearner()
For the LBJava compiler; not for use by the LBJava user.
|
MuxLearner(Learner base)
Instantiates this multiplexed learner using the specified base learning algorithm.
|
MuxLearner(Learner base,
String d)
Instantiates this multiplexed learner using the specified base learning algorithm.
|
MuxLearner(MuxLearner.Parameters p)
Initializing constructor.
|
MuxLearner(String n)
For the LBJava compiler; not for use by the LBJava user.
|
MuxLearner(String n,
Learner base)
Instantiates this multiplexed learner using the specified base learning algorithm.
|
MuxLearner(String n,
Learner base,
String d)
Instantiates this multiplexed learner using the specified base learning algorithm.
|
MuxLearner(String n,
MuxLearner.Parameters p)
Initializing constructor.
|
Modifier and Type | Method and Description |
---|---|
FeatureVector |
classify(int[] exampleFeatures,
double[] exampleValues)
This method performs the multiplexing and returns the output of the selected
Learner . |
Object |
clone()
Returns a deep clone of this learning algorithm.
|
String |
discreteValue(int[] exampleFeatures,
double[] exampleValues)
Returns the value of the discrete feature that would be returned by this classifier.
|
Feature |
featureValue(int[] f,
double[] v)
Returns the classification of the given example as a single feature instead of a
FeatureVector . |
void |
forget()
Clears the network.
|
Learner.Parameters |
getParameters()
Retrieves the parameters that are set in this learner.
|
void |
learn(int[] exampleFeatures,
double[] exampleValues,
int[] exampleLabels,
double[] labelValues)
The training example is multiplexed to the appropriate
Learner (s). |
void |
read(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in)
Reads the binary representation of a learner with this object's run-time type, overwriting
any and all learned or manually specified parameters as well as the label lexicon but without
modifying the feature lexicon.
|
double |
realValue(int[] f,
double[] v)
Returns the value of the real feature that would be returned by this classifier.
|
ScoreSet |
scores(int[] exampleFeatures,
double[] exampleValues)
Produces a set of scores indicating the degree to which each possible discrete classification
value is associated with the given example object.
|
void |
setBase(Learner base)
Sets
baseLearner . |
protected void |
setDefaultFeature()
Sets the value of
defaultFeature according to the current value of
defaultPrediction . |
void |
setLabeler(Classifier l)
Sets the labeler.
|
void |
setLabelLexicon(Lexicon l)
Sets the label lexicon.
|
void |
setParameters(MuxLearner.Parameters p)
Sets the values of parameters that control the behavior of this learning algorithm.
|
void |
write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
Writes the learned function's internal representation in binary form.
|
void |
write(PrintStream out)
Writes the algorithm's internal representation as text.
|
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, initialize, learn, learn, learn, learn, read, readLabelLexicon, readLearner, readLearner, readLearner, readLearner, readLearner, readLearner, readLexicon, readLexicon, readLexiconOnDemand, readLexiconOnDemand, readModel, readModel, readParameters, realValue, realValue, save, saveLexicon, saveModel, scores, scores, scoresAugmented, setCandidates, setEncoding, setExtractor, setLexicon, setLexiconLocation, setLexiconLocation, setLossFlag, setModelLocation, setModelLocation, setParameters, setReadLexiconOnDemand, unclone, unsetLossFlag, write, writeLexicon, writeModel, writeParameters
allowableValues, classify, discreteValueArray, getCompositeChildren, getInputType, getOutputType, realValueArray, test, toString, valueIndexOf
public static final Learner defaultBaseLearner
baseLearner
.public static final String defaultDefaultPrediction
defaultPrediction
.protected Learner baseLearner
null
.protected edu.illinois.cs.cogcomp.core.datastructures.vectors.OVector network
protected String defaultPrediction
Learner
doesn't
exist; default defaultDefaultPrediction
.protected Feature defaultFeature
defaultPrediction
.public MuxLearner()
public MuxLearner(Learner base)
base
- Instances of this learner will be multiplexed.public MuxLearner(Learner base, String d)
base
- Instances of this learner will be multiplexed.d
- This prediction will be returned during testing when the multiplexed
Learner
does not exist.public MuxLearner(MuxLearner.Parameters p)
MuxLearner.Parameters
object.p
- The settings of all parameters.public MuxLearner(String n)
public MuxLearner(String n, Learner base)
n
- The name of the classifier.base
- Instances of this learner will be multiplexed.public MuxLearner(String n, Learner base, String d)
n
- The name of the classifier.base
- Instances of this learner will be multiplexed.d
- This prediction will be returned during testing when the multiplexed
Learner
does not exist.public MuxLearner(String n, MuxLearner.Parameters p)
MuxLearner.Parameters
object.n
- The name of the classifier.p
- The settings of all parameters.public void setParameters(MuxLearner.Parameters p)
p
- The parameters.protected void setDefaultFeature()
defaultFeature
according to the current value of
defaultPrediction
.public Learner.Parameters getParameters()
getParameters
in class Learner
public void setBase(Learner base)
baseLearner
. This method will not have any effect on the learners that
already exist in the network. However, new learners created after this method is executed
will be of the same type as the object specified.base
- The new base learning algorithm.public void setLabeler(Classifier l)
setLabeler
in class Learner
l
- A labeling classifier.public void setLabelLexicon(Lexicon l)
setLabelLexicon
in class Learner
l
- A feature lexicon.public void learn(int[] exampleFeatures, double[] exampleValues, int[] exampleLabels, double[] labelValues)
Learner
(s).public ScoreSet scores(int[] exampleFeatures, double[] exampleValues)
Learner
's scores(Object)
method.scores
in class Learner
exampleFeatures
- The example's array of feature indices.exampleValues
- The example's array of feature values.Learner.scores(Object)
public String discreteValue(int[] exampleFeatures, double[] exampleValues)
discreteValue
in class Learner
exampleFeatures
- The example's array of feature indices.exampleValues
- The example's array of feature values.public double realValue(int[] f, double[] v)
public Feature featureValue(int[] f, double[] v)
FeatureVector
.featureValue
in class Learner
f
- The features array.v
- The values array.public FeatureVector classify(int[] exampleFeatures, double[] exampleValues)
Learner
.public void write(PrintStream out)
public void write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
public void read(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in)
Copyright © 2016. All rights reserved.