edu.cmu.cs.sb.drem
Class DREM_FastLogistic2

java.lang.Object
  extended by edu.cmu.cs.sb.drem.DREM_FastLogistic2

public final class DREM_FastLogistic2
extends java.lang.Object

Class implements a logistic regression classifier trained with an L1 penalty. The L1 penalty promotes sparsity in the classifier Implementation based on the following paper Krishnapuram, B., Figueiredo, M., Carin, L., and Hartemink, A. Sparse Multinomial Logistic Regression: Fast Algorithms and Generalization Bounds. IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI), 27, June 2005. pp. 957-968.


Constructor Summary
DREM_FastLogistic2()
          Empty constructor
DREM_FastLogistic2(int[][] traindataindex, int[][] traindata, int[][] traindataTFindex, int[][] traindataTF, int[] y, double[] dtrainweight, int numclasses, int numbits)
          Constructor where the training weights of the instances are given
DREM_FastLogistic2(int[][] traindataindex, int[][] traindata, int[][] traindataTFindex, int[][] traindataTF, int[] y, int numclasses, double[] dcoeff, int numbits)
          Constructor where the coefficients are given to the classifier
 
Method Summary
 java.lang.Object clone()
          Clones the classifier
 void computeG(int nel, boolean bnew, boolean bfirsttime)
          Updates the G parameters in the multi-class case bnew means the coefficient changed on the previous coordinate or first time if didn't change then can keep previous errors just update current coefficient bfirsttime means it is the first pass through the coeffienients
 void computeGbin(int nel, boolean bnew, boolean bfirsttime)
          Updates the value of the G matrix for the binary case bnew means the coefficient changed on the previous coordinate or first time If didn't change then can keep previous errors just update current coefficient bfirsttime means it is the first pass through the coefficients
 double[] distributionForInstance(int[] theInstance, int nrow)
          Returns a probability distribution the classifier gives to each class for the provided instance
 double[] distributionForInstance(int[] theInstanceIndex, int[] theInstance, int nrow)
          Returns a probability distribution the classifier gives to each class for the provided instance
 boolean nextw(int nel, boolean bnew, boolean bfirst)
          For the multi-class case updates the value of dcoeff[nel]
 boolean nextwbin(int nel, boolean bnew, boolean bfirst)
          For the binary case updates the value of dcoeff[nel]
 double p(int nindicator, int nrow)
          Computes the probability of the item in nrow is of class nindicator
 void reinit(int[][] traindataindex, int[][] traindata, int[][] traindataTFindex, int[][] traindataTF, int[] y, double[] dtrainweight, int numclasses)
          Reinitialized the variables of the classifier based on the input parameters
 java.lang.String saveClassifier(java.lang.String[] tfNames)
          Returns a string with the classifier parameters
 void setRidge(double dridge)
          Sets the value of the ridge parameter
 double soft(double da, double ddelta)
          If abs(da)-ddelta less than or equal to 0 returns 0 otherwise if da is non-negative returns abs(da)-ddelta and otherwide returns -(abs(da)-ddelta)
 java.lang.String toString()
          Convers the classifier into a string
 void train()
          Calss either trainbin or trainmulti to train the parameters of the classifier
 void trainbin()
          Trains the parameters in the binary case
 void trainmulti()
          Trains the parameters in the multi-class case
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DREM_FastLogistic2

public DREM_FastLogistic2()
Empty constructor


DREM_FastLogistic2

public DREM_FastLogistic2(int[][] traindataindex,
                          int[][] traindata,
                          int[][] traindataTFindex,
                          int[][] traindataTF,
                          int[] y,
                          int numclasses,
                          double[] dcoeff,
                          int numbits)
Constructor where the coefficients are given to the classifier


DREM_FastLogistic2

public DREM_FastLogistic2(int[][] traindataindex,
                          int[][] traindata,
                          int[][] traindataTFindex,
                          int[][] traindataTF,
                          int[] y,
                          double[] dtrainweight,
                          int numclasses,
                          int numbits)
Constructor where the training weights of the instances are given

Method Detail

clone

public java.lang.Object clone()
Clones the classifier

Overrides:
clone in class java.lang.Object

setRidge

public void setRidge(double dridge)
Sets the value of the ridge parameter


toString

public java.lang.String toString()
Convers the classifier into a string

Overrides:
toString in class java.lang.Object

saveClassifier

public java.lang.String saveClassifier(java.lang.String[] tfNames)
Returns a string with the classifier parameters


reinit

public void reinit(int[][] traindataindex,
                   int[][] traindata,
                   int[][] traindataTFindex,
                   int[][] traindataTF,
                   int[] y,
                   double[] dtrainweight,
                   int numclasses)
Reinitialized the variables of the classifier based on the input parameters


soft

public double soft(double da,
                   double ddelta)
If abs(da)-ddelta less than or equal to 0 returns 0 otherwise if da is non-negative returns abs(da)-ddelta and otherwide returns -(abs(da)-ddelta)


p

public double p(int nindicator,
                int nrow)
Computes the probability of the item in nrow is of class nindicator


computeG

public void computeG(int nel,
                     boolean bnew,
                     boolean bfirsttime)
Updates the G parameters in the multi-class case bnew means the coefficient changed on the previous coordinate or first time if didn't change then can keep previous errors just update current coefficient bfirsttime means it is the first pass through the coeffienients


computeGbin

public void computeGbin(int nel,
                        boolean bnew,
                        boolean bfirsttime)
Updates the value of the G matrix for the binary case bnew means the coefficient changed on the previous coordinate or first time If didn't change then can keep previous errors just update current coefficient bfirsttime means it is the first pass through the coefficients


nextw

public boolean nextw(int nel,
                     boolean bnew,
                     boolean bfirst)
For the multi-class case updates the value of dcoeff[nel]


nextwbin

public boolean nextwbin(int nel,
                        boolean bnew,
                        boolean bfirst)
For the binary case updates the value of dcoeff[nel]


distributionForInstance

public double[] distributionForInstance(int[] theInstance,
                                        int nrow)
Returns a probability distribution the classifier gives to each class for the provided instance


distributionForInstance

public double[] distributionForInstance(int[] theInstanceIndex,
                                        int[] theInstance,
                                        int nrow)
Returns a probability distribution the classifier gives to each class for the provided instance


train

public void train()
Calss either trainbin or trainmulti to train the parameters of the classifier


trainmulti

public void trainmulti()
Trains the parameters in the multi-class case


trainbin

public void trainbin()
Trains the parameters in the binary case