edu.cmu.minorthird.classify.algorithms.linear
Class Hyperplane

java.lang.Object
  extended by edu.cmu.minorthird.classify.BinaryClassifier
      extended by edu.cmu.minorthird.classify.algorithms.linear.Hyperplane
All Implemented Interfaces:
Classifier, Visible, java.io.Serializable

public class Hyperplane
extends BinaryClassifier
implements Visible, java.io.Serializable

A weighted combination of features.

Author:
William Cohen
See Also:
Serialized Form

Field Summary
static Feature BIAS_TERM
          Weight for an invisible 'bias feature' which is considered to be present in every instance.
protected  gnu.trove.TObjectDoubleHashMap hyperplaneWeights
           
 
Fields inherited from class edu.cmu.minorthird.classify.BinaryClassifier
classifierLearner
 
Constructor Summary
Hyperplane()
           
 
Method Summary
 java.lang.String explain(Instance instance)
          Justify inner product of hyperplane and instance weights.
 java.util.Iterator<Feature> featureIterator()
          Iterate over all features with non-zero weight.
 double featureScore(Feature feature)
          Weight for a feature in the hyperplane.
 Explanation getExplanation(Instance instance)
          Return an Explanation for the classification
 boolean hasFeature(Feature feat)
          Checks the presence of a feature in hyperplane
 void increment(Feature f, double delta)
          Increment one feature from the hyperplane by delta
 void increment(Hyperplane b)
          Add hyperplane b to this hyperplane.
 void increment(Hyperplane b, double delta)
          Add hyperplane b*delta to this hyperplane.
 void increment(Instance instance, double delta)
          Add the value of the features in the instance to this hyperplane.
 void incrementBias(double delta)
          Increment the bias term for the hyperplane by delta
 void multiply(double factor)
          Multiply all weights by a factor
 void multiply(Feature f, double delta)
          Multiply one feature from the hyperplane by delta
 double score(Instance instance)
          Inner product of hyperplane and instance weights.
 void setBias(double delta)
          Set the bias term for the hyperplane to delta
 void startIgnoringWeights()
          After this call is made, the hyperplane will assume that all feature weights are one in instances.
 Viewer toGUI()
          Create a view of this object
 java.lang.String toString()
           
 
Methods inherited from class edu.cmu.minorthird.classify.BinaryClassifier
classification, getClassifierLearner, setClassifierLearner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BIAS_TERM

public static final Feature BIAS_TERM
Weight for an invisible 'bias feature' which is considered to be present in every instance. In otherwords, as a classifier, the score of a hyperplane h on an instance x is sum_{feature f} x.score(f)*h.featureScore(f) + h.featureScore(BIAS_TERM).


hyperplaneWeights

protected transient gnu.trove.TObjectDoubleHashMap hyperplaneWeights
Constructor Detail

Hyperplane

public Hyperplane()
Method Detail

startIgnoringWeights

public void startIgnoringWeights()
After this call is made, the hyperplane will assume that all feature weights are one in instances. Specifically in calls to increment(instance,delta) or increment(hyperplane,delta), feature weights will be assumed to be one. For backward compatibility with an old buggy version.


score

public double score(Instance instance)
Inner product of hyperplane and instance weights.

Specified by:
score in class BinaryClassifier

explain

public java.lang.String explain(Instance instance)
Justify inner product of hyperplane and instance weights.

Specified by:
explain in interface Classifier

getExplanation

public Explanation getExplanation(Instance instance)
Description copied from interface: Classifier
Return an Explanation for the classification

Specified by:
getExplanation in interface Classifier

increment

public void increment(Feature f,
                      double delta)
Increment one feature from the hyperplane by delta


incrementBias

public void incrementBias(double delta)
Increment the bias term for the hyperplane by delta


setBias

public void setBias(double delta)
Set the bias term for the hyperplane to delta


increment

public void increment(Instance instance,
                      double delta)
Add the value of the features in the instance to this hyperplane.


multiply

public void multiply(double factor)
Multiply all weights by a factor


multiply

public void multiply(Feature f,
                     double delta)
Multiply one feature from the hyperplane by delta


hasFeature

public boolean hasFeature(Feature feat)
Checks the presence of a feature in hyperplane


increment

public void increment(Hyperplane b,
                      double delta)
Add hyperplane b*delta to this hyperplane.


increment

public void increment(Hyperplane b)
Add hyperplane b to this hyperplane.


featureScore

public double featureScore(Feature feature)
Weight for a feature in the hyperplane.


featureIterator

public java.util.Iterator<Feature> featureIterator()
Iterate over all features with non-zero weight.


toGUI

public Viewer toGUI()
Description copied from interface: Visible
Create a view of this object

Specified by:
toGUI in interface Visible

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object