Class LogisticRegressionClassifier<U>

java.lang.Object
es.uam.eps.ir.relison.links.linkprediction.supervised.classifiers.LogisticRegressionClassifier<U>
Type Parameters:
U - type of the users.
All Implemented Interfaces:
Classifier<U>

public class LogisticRegressionClassifier<U>
extends java.lang.Object
implements Classifier<U>
Classifier that applies a logistic regression (i.e. finds a linear separation between elements in both positive and negative classes).

Reference: Bishop,C.M.Instance Recognition and Machine Learning, Springer, 2006, pp. 205-207

  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.util.List<java.lang.Integer> classes
    List of classes.
    private int dimension
    Number of attributes of the problem, including the class.
    private double eta
    Learning coefficient of the classifier.
    private int maxEpochs
    Maximum number of iterations which the algorithm will run during training.
    private boolean normalize
    True if the patterns have to be normalized.
    private Vector omega
    Vector that determines the hyperplane which separates both classes.
    private static double RANGEMAX
    Maximum possible initial value for each coordinate of the omega vector
    private static double RANGEMIN
    Minimum possible initial value for each coordinate of the omega vector
    private java.util.List<es.uam.eps.ir.ranksys.core.util.Stats> stats
    The list of stats for each attribute.
    private static double THRESHOLD
    When the difference between the previous iteration of the algorithm and the current is smaller than this value, the algorithm stops.
    private boolean trained
    Indicates if the classifier has been trained.
  • Constructor Summary

    Constructors 
    Constructor Description
    LogisticRegressionClassifier​(double eta, int maxEpochs)
    Constructor.
    LogisticRegressionClassifier​(double eta, int maxEpochs, boolean normalize)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    int classify​(Instance<U> instance)
    Obtains the most likely class for a certain instance.
    double computeScore​(Instance<U> instance, int category)
    Gets the score for an individual pattern in a certain category.
    java.util.Map<java.lang.Integer,​java.lang.Double> computeScores​(Instance<U> instance)
    Computes the scores for an individual instance (once the training has been done).
    void train​(InstanceSet<U> trainSet)
    Trains the classifier.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dimension

      private int dimension
      Number of attributes of the problem, including the class.
    • omega

      private Vector omega
      Vector that determines the hyperplane which separates both classes.
    • eta

      private final double eta
      Learning coefficient of the classifier. Controls the convergence speed of the classifier. Greater values may lead to bad convergence, but very small values make the convergence very slow.
    • maxEpochs

      private final int maxEpochs
      Maximum number of iterations which the algorithm will run during training.
    • RANGEMIN

      private static final double RANGEMIN
      Minimum possible initial value for each coordinate of the omega vector
      See Also:
      Constant Field Values
    • RANGEMAX

      private static final double RANGEMAX
      Maximum possible initial value for each coordinate of the omega vector
      See Also:
      Constant Field Values
    • THRESHOLD

      private static final double THRESHOLD
      When the difference between the previous iteration of the algorithm and the current is smaller than this value, the algorithm stops.
      See Also:
      Constant Field Values
    • classes

      private java.util.List<java.lang.Integer> classes
      List of classes.
    • normalize

      private final boolean normalize
      True if the patterns have to be normalized.
    • stats

      private java.util.List<es.uam.eps.ir.ranksys.core.util.Stats> stats
      The list of stats for each attribute.
    • trained

      private boolean trained
      Indicates if the classifier has been trained.
  • Constructor Details

    • LogisticRegressionClassifier

      public LogisticRegressionClassifier​(double eta, int maxEpochs)
      Constructor.
      Parameters:
      eta - the learning coefficient of the classifier.
      maxEpochs - the maximum number of iterations.
    • LogisticRegressionClassifier

      public LogisticRegressionClassifier​(double eta, int maxEpochs, boolean normalize)
      Constructor.
      Parameters:
      eta - the learning coefficient of the classifier.
      maxEpochs - the maximum number of iterations.
      normalize - indicates if the data has to be normalized.
  • Method Details

    • train

      public void train​(InstanceSet<U> trainSet)
      Description copied from interface: Classifier
      Trains the classifier.
      Specified by:
      train in interface Classifier<U>
      Parameters:
      trainSet - the training set.
    • computeScores

      public java.util.Map<java.lang.Integer,​java.lang.Double> computeScores​(Instance<U> instance)
      Description copied from interface: Classifier
      Computes the scores for an individual instance (once the training has been done).
      Specified by:
      computeScores in interface Classifier<U>
      Parameters:
      instance - the individual instance.
      Returns:
      A score for each class.
    • computeScore

      public double computeScore​(Instance<U> instance, int category)
      Description copied from interface: Classifier
      Gets the score for an individual pattern in a certain category.
      Specified by:
      computeScore in interface Classifier<U>
      Parameters:
      instance - the pattern.
      category - the class.
      Returns:
      the score.
    • classify

      public int classify​(Instance<U> instance)
      Description copied from interface: Classifier
      Obtains the most likely class for a certain instance.
      Specified by:
      classify in interface Classifier<U>
      Parameters:
      instance - the individual instance.
      Returns:
      The most likely class.