types
Class LinearClassifier

java.lang.Object
  extended by types.LinearClassifier

public class LinearClassifier
extends Object

A linear model for classification. It has the form h(x) = arg_max_y f(x,y).w

Author:
kuzman

Field Summary
 double[] w
           
 Alphabet xAlphabet
           
 Alphabet yAlphabet
           
 
Constructor Summary
LinearClassifier(Alphabet xAlpha, Alphabet yAlpha, FeatureFunction fxy)
           
 
Method Summary
 int label(SparseVector x)
          computes the classification according to this linear classifier.
 void readObject(ObjectInputStream in)
           
 double[] scores(SparseVector x)
          computes the score of each label 'y' defined as f(x,y) .
 void writeObject(ObjectOutputStream out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

w

public double[] w

yAlphabet

public Alphabet yAlphabet

xAlphabet

public Alphabet xAlphabet
Constructor Detail

LinearClassifier

public LinearClassifier(Alphabet xAlpha,
                        Alphabet yAlpha,
                        FeatureFunction fxy)
Method Detail

scores

public double[] scores(SparseVector x)
computes the score of each label 'y' defined as f(x,y) . w

Parameters:
x -
Returns:
[f(x,0).w, f(x,1).w, ...]

label

public int label(SparseVector x)
computes the classification according to this linear classifier. arg_max_y f(x,y) . w

Parameters:
x -
Returns:
y that maximizes f(x,y) . w

writeObject

public void writeObject(ObjectOutputStream out)
                 throws IOException
Throws:
IOException

readObject

public void readObject(ObjectInputStream in)
                throws IOException,
                       ClassNotFoundException
Throws:
IOException
ClassNotFoundException


Copyright © 2009. All Rights Reserved.