types
Class StaticUtils

java.lang.Object
  extended by types.StaticUtils

public class StaticUtils
extends Object

Some methods that are useful to have in linear models.

Author:
kuzman

Constructor Summary
StaticUtils()
           
 
Method Summary
static void add(double[] u, double[] v, double[] w, double d)
          u = v + d*w
static int argmax(double[] v)
          computes arg max_i v[i]
static double computeAccuracy(LinearClassifier h, ArrayList<ClassificationInstance> data)
          The accuracy of classifier h on the data set data.
static double computeAccuracyS(LinearTagger h, ArrayList<SequenceInstance> data)
          The accuracy of classifier h on the data set data.
static double dotProduct(double[] v, double[] w)
           
static double dotProduct(SparseVector v, double[] w)
          the dot product between a sparse vector v and a dense vector w.
static double[] exp(double[] vec)
          res = exp(vec)
static double[][] exp(double[][] vec)
          res = exp(vec)
static double[][][] exp(double[][][] vec)
          res = exp(vec)
static LinearTagger loadTagger(String fname)
           
static SparseVector lookupCollection(Collection<String> in, Alphabet a)
           
static void plusEquals(double[] w, double[] v, double d)
          w <- w + d*v
static void plusEquals(double[] w, SparseVector v)
          update: w = w + v
static void plusEquals(double[] w, SparseVector v, double d)
          w <- w + d*v
static void plusEquals(SparseVector w, SparseVector v)
          w <- w + v
static void saveTagger(LinearTagger h, String fname)
           
static void shuffle(ArrayList list, long seed)
          shuffle a list (intended as a list of instances) in place using seed as the random seed.
static ArrayList<ClassificationInstance>[] split(ArrayList<ClassificationInstance> l, int splitAt)
           
static ArrayList<SequenceInstance>[] splitS(ArrayList<SequenceInstance> l, int splitAt)
           
static double sum(double[] probs)
           
static double twoNormSquared(double[] w)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticUtils

public StaticUtils()
Method Detail

dotProduct

public static double dotProduct(SparseVector v,
                                double[] w)
the dot product between a sparse vector v and a dense vector w.


dotProduct

public static double dotProduct(double[] v,
                                double[] w)

shuffle

public static void shuffle(ArrayList list,
                           long seed)
shuffle a list (intended as a list of instances) in place using seed as the random seed.


computeAccuracyS

public static double computeAccuracyS(LinearTagger h,
                                      ArrayList<SequenceInstance> data)
The accuracy of classifier h on the data set data. This is just the number of correct tokens divided by the number of tokens.


computeAccuracy

public static double computeAccuracy(LinearClassifier h,
                                     ArrayList<ClassificationInstance> data)
The accuracy of classifier h on the data set data. This is just the number of correct instance divided by the number of instances.


split

public static ArrayList<ClassificationInstance>[] split(ArrayList<ClassificationInstance> l,
                                                        int splitAt)

splitS

public static ArrayList<SequenceInstance>[] splitS(ArrayList<SequenceInstance> l,
                                                   int splitAt)

plusEquals

public static void plusEquals(double[] w,
                              SparseVector v)
update: w = w + v


exp

public static double[] exp(double[] vec)
res = exp(vec)


exp

public static double[][] exp(double[][] vec)
res = exp(vec)


exp

public static double[][][] exp(double[][][] vec)
res = exp(vec)


twoNormSquared

public static double twoNormSquared(double[] w)
Parameters:
w -
Returns:
sum_i w[i]^2

sum

public static double sum(double[] probs)
Parameters:
probs -
Returns:
sum_i probs[i]

plusEquals

public static void plusEquals(SparseVector w,
                              SparseVector v)
w <- w + v


plusEquals

public static void plusEquals(double[] w,
                              SparseVector v,
                              double d)
w <- w + d*v


plusEquals

public static void plusEquals(double[] w,
                              double[] v,
                              double d)
w <- w + d*v


add

public static void add(double[] u,
                       double[] v,
                       double[] w,
                       double d)
u = v + d*w


argmax

public static int argmax(double[] v)
computes arg max_i v[i]


lookupCollection

public static SparseVector lookupCollection(Collection<String> in,
                                            Alphabet a)

saveTagger

public static void saveTagger(LinearTagger h,
                              String fname)
                       throws IOException
Throws:
IOException

loadTagger

public static LinearTagger loadTagger(String fname)
                               throws IOException,
                                      ClassNotFoundException
Throws:
IOException
ClassNotFoundException


Copyright © 2009. All Rights Reserved.