|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnetkit.classifiers.ClassifierImp
netkit.classifiers.relational.NetworkClassifierImp
public abstract class NetworkClassifierImp
Core implementation of the NetworkClassifier (and Classifier) interface. All methods that are generic have been implemented (although they can be overridden to be customized as necessary). It extends the core implementation of the basic Classifier interface (ClassifierImp) and implements only the methods that are specifically relational in nature.
The only four methods that any subclass need to implement are:
public boolean doEstimate(Node n, double[] result)
public String getName()
public String getShortName()
Returns the short name of the classifier. e.g.: cdRN
public String getDescription()
In addition, the classifier ought to override the
public void induceModel(Graph graph, DataSplit split)
method, which does the actual learning.
You may also want to override the getDefaultConfiguration()
and
configure(Configuration config)
methods if the classifier can be
configured in any special way (e.g., if it can take some parameters).
Finally, if the classifier needs to do some book-keeping at every run of the
collective inference method, the you should override
initializeRun(Estimate currPrior, Node[] unknowns)
Properties:
doEstimate(netkit.graph.Node, double[])
,
Classifier.getName()
,
Classifier.getShortName()
,
Classifier.getDescription()
,
induceModel(netkit.graph.Graph, netkit.classifiers.DataSplit)
,
getDefaultConfiguration()
,
configure(netkit.util.Configuration)
,
initializeRun(netkit.classifiers.Estimate, netkit.graph.Node[])
Nested Class Summary | |
---|---|
protected static class |
NetworkClassifierImp.Aggregation
The possible ways the relational classifier can handle aggregation. |
Field Summary | |
---|---|
protected static AggregatorFactory |
aggFactory
Get the aggregator factory, which will be used to get the aggregators needed for the classifier. |
protected NetworkClassifierImp.Aggregation |
aggregation
What kind of aggregation should the classifier do. |
protected java.util.List<Aggregator> |
aggregators
This list contains all the aggregators for an input graph. |
protected java.lang.String[] |
aggTypes
This array contains the list of aggregators that this classifier will use. |
protected java.util.List<Aggregator> |
dynamicAggregators
This list contains the 'dynamic' aggregators... |
protected Estimate |
prior
This keeps track of the priors for the unknown nodes. |
Fields inherited from class netkit.classifiers.ClassifierImp |
---|
attribute, classPrior, clsIdx, graph, keyIndex, logger, nodeType, right, tmpVector, useIntrinsic, vectorClsIdx |
Constructor Summary | |
---|---|
NetworkClassifierImp()
|
Method Summary | |
---|---|
int |
classify(Node node,
Estimate prior,
boolean updatePrior)
Classify a given node into one of the given classes. |
void |
configure(Configuration config)
Configure the classifier. |
protected abstract boolean |
doEstimate(Node node,
double[] result)
This is the final estimation method that will be called and the only estimation method that sub-classes should implement. |
boolean |
estimate(Node node,
double[] result)
Estimate the probabilities that a given node into belongs to any given class. |
double[] |
estimate(Node node,
Estimate prior,
boolean updatePrior)
Estimate the probabilities that a given node into belongs to any given class It may use the class estimations of other nodes and may update the prior of the given node. |
boolean |
estimate(Node node,
Estimate prior,
double[] result,
boolean updatePrior)
Estimate the probabilities that a given node into belongs to any given class It may use the class estimations of other nodes and may update the prior of the given node. |
boolean |
estimate(Node node,
Estimate prior,
Estimate result,
boolean updatePrior)
Estimate the probabilities that a given node into belongs to any given class It may use the class estimations of other nodes and may update the prior of the given node. |
protected void |
generateAggregators()
This generates all the aggregator instances needed to create all the aggregated values for all the attributes as directed by the configuration. |
protected java.lang.String[] |
getAttributeNames()
|
Configuration |
getDefaultConfiguration()
Default configuration for relational learners. |
protected boolean |
includeClassAttribute()
Method to tell this object whether to include the class attribute when creating the internal instance representation for relational learning. |
void |
induceModel(Graph graph,
DataSplit split)
This method induces a new prediction model. |
void |
initializeRun(Estimate currPrior,
Node[] unknowns)
This is called prior to predicting labels for the unknown labels in the graph, in case the classifier needs to initialize itself. |
protected void |
makeVector(Node node,
double[] vector)
|
Methods inherited from class netkit.classifiers.ClassifierImp |
---|
addListener, classify, classify, clearListeners, estimate, estimate, getLogger, getNofifyListeners, notifyListeners, notifyListeners, removeListener, reset, setNofityListeners |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface netkit.classifiers.Classifier |
---|
addListener, classify, classify, clearListeners, estimate, estimate, getDescription, getLogger, getName, getNofifyListeners, getShortName, notifyListeners, notifyListeners, removeListener, reset, setNofityListeners |
Field Detail |
---|
protected static AggregatorFactory aggFactory
protected Estimate prior
protected NetworkClassifierImp.Aggregation aggregation
protected java.lang.String[] aggTypes
protected java.util.List<Aggregator> aggregators
protected java.util.List<Aggregator> dynamicAggregators
Constructor Detail |
---|
public NetworkClassifierImp()
Method Detail |
---|
protected abstract boolean doEstimate(Node node, double[] result)
node
- The node whose class label needs to be estimatedresult
- The array to be filled with estimations for the class label
protected boolean includeClassAttribute()
public Configuration getDefaultConfiguration()
These are also the configuration objects that are set in this instance. If a
classifier needs more, then it should override this (remembering to call
super.getDefaultConfiguration()
if needed) to set other default
configuration options.
getDefaultConfiguration
in interface Configurable
getDefaultConfiguration
in class ClassifierImp
public void configure(Configuration config)
configure
in interface Configurable
configure
in class ClassifierImp
config
- The Configuration object used to configure this classifier.aggregation
protected void generateAggregators()
aggregators
List with these aggregators, which
will then be used to convert an instance into a 'learning instance' by adding
these aggregated values.
aggregators
,
dynamicAggregators
public void induceModel(Graph graph, DataSplit split)
super.induceModel(graph,split)
to ensure that all internal
variables have been set.
This method sets up crucial information needed for internal use. Of general interest,
it resets the aggregators list to the new list of aggregators (by calling
generateAggregators()
and sets certain internal variables such as
tmpVector and vectorClsIdx.
induceModel
in interface Classifier
induceModel
in class ClassifierImp
graph
- The graph over which to induce a modelsplit
- The datasplit which informs us which nodes have known class labels and which do notgenerateAggregators()
,
aggregators
,
ClassifierImp.induceModel(netkit.graph.Graph, netkit.classifiers.DataSplit)
,
ClassifierImp.tmpVector
,
ClassifierImp.vectorClsIdx
protected java.lang.String[] getAttributeNames()
getAttributeNames
in class ClassifierImp
protected void makeVector(Node node, double[] vector)
makeVector
in class ClassifierImp
public void initializeRun(Estimate currPrior, Node[] unknowns)
initializeRun
in interface NetworkClassifier
currPrior
- The current 'priors' or estimates of the unknown lablesunknowns
- The list of nodes which are to be predicted in the upcoming run.public final int classify(Node node, Estimate prior, boolean updatePrior)
This method is final and calls the
estimate(Node,Estimate,double[],boolean)
method with false
as the boolean as this takes care of that boolean if neccessary (by updating the
prior object). It also notifies any listeners that the label of this node has
been predicted.
classify
in interface NetworkClassifier
node
- The node to classify.prior
- The current class estimates of all initially unknown nodes.updatePrior
- Whether the classifier should update the prior of the node that it classifies. If true, then the
prior object is updated with the predicted classification.
estimate(netkit.graph.Node, netkit.classifiers.Estimate, double[], boolean)
,
ClassifierImp.notifyListeners(netkit.graph.Node, int)
public final boolean estimate(Node node, Estimate prior, double[] result, boolean updatePrior)
This method is final and sets the prior object before it calls
estimate(Node,double[])
to do the actual estimate.
It takes care of the prior if necessary (by updating the prior object)
estimate
in interface NetworkClassifier
node
- The node to estimate.prior
- The current class estimates of all initially unknown nodes.result
- The array that is filled in with class estimatesupdatePrior
- Whether the classifier should update the prior of the node that it classifies. If true, then the
prior object is updated with the new estimates.
estimate(netkit.graph.Node, double[])
,
prior
public final double[] estimate(Node node, Estimate prior, boolean updatePrior)
This method is final and calls the
estimate(Node,Estimate,double[],boolean)
method using a temporary
double array, which is returned if the classifier does not abstain. If it abstains
(the called estimate method returns false), then this method returns null.
estimate
in interface NetworkClassifier
node
- The node to estimate.prior
- The current class estimates of all initially unknown nodes.updatePrior
- Whether the classifier should update the prior of the node that it classifies. If true, then the
prior object is updated with the new estimates.
null
is the classifier abstainsestimate(netkit.graph.Node, netkit.classifiers.Estimate, double[], boolean)
public final boolean estimate(Node node, Estimate prior, Estimate result, boolean updatePrior)
This method is final and calls the
estimate(Node,Estimate,double[],boolean)
method.
estimate
in interface NetworkClassifier
node
- The node to estimate.prior
- The current class estimates of all initially unknown nodes.result
- The Estimate object that is updated with class estimates.updatePrior
- Whether the classifier should update the prior of the node that it classifies. If true, then the
prior object is updated with the new estimates.
estimate(netkit.graph.Node, netkit.classifiers.Estimate, double[], boolean)
public final boolean estimate(Node node, double[] result)
This method is final and calls the
doEstimate(Node,Estimate,double[],boolean)
method. It also notifies any listeners
that the label for this node has been estimated.
estimate
in interface Classifier
node
- The node to estimate.result
- The Estimate object that is updated with class estimates.
doEstimate(netkit.graph.Node, double[])
,
ClassifierImp.notifyListeners(netkit.graph.Node, double[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |