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>classesList of classes.private intdimensionNumber of attributes of the problem, including the class.private doubleetaLearning coefficient of the classifier.private intmaxEpochsMaximum number of iterations which the algorithm will run during training.private booleannormalizeTrue if the patterns have to be normalized.private VectoromegaVector that determines the hyperplane which separates both classes.private static doubleRANGEMAXMaximum possible initial value for each coordinate of the omega vectorprivate static doubleRANGEMINMinimum possible initial value for each coordinate of the omega vectorprivate java.util.List<es.uam.eps.ir.ranksys.core.util.Stats>statsThe list of stats for each attribute.private static doubleTHRESHOLDWhen the difference between the previous iteration of the algorithm and the current is smaller than this value, the algorithm stops.private booleantrainedIndicates 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 intclassify(Instance<U> instance)Obtains the most likely class for a certain instance.doublecomputeScore(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).voidtrain(InstanceSet<U> trainSet)Trains the classifier.
-
Field Details
-
dimension
private int dimensionNumber of attributes of the problem, including the class. -
omega
Vector that determines the hyperplane which separates both classes. -
eta
private final double etaLearning 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 maxEpochsMaximum number of iterations which the algorithm will run during training. -
RANGEMIN
private static final double RANGEMINMinimum possible initial value for each coordinate of the omega vector- See Also:
- Constant Field Values
-
RANGEMAX
private static final double RANGEMAXMaximum possible initial value for each coordinate of the omega vector- See Also:
- Constant Field Values
-
THRESHOLD
private static final double THRESHOLDWhen 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> classesList of classes. -
normalize
private final boolean normalizeTrue if the patterns have to be normalized. -
stats
private java.util.List<es.uam.eps.ir.ranksys.core.util.Stats> statsThe list of stats for each attribute. -
trained
private boolean trainedIndicates 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
Description copied from interface:ClassifierTrains the classifier.- Specified by:
trainin interfaceClassifier<U>- Parameters:
trainSet- the training set.
-
computeScores
Description copied from interface:ClassifierComputes the scores for an individual instance (once the training has been done).- Specified by:
computeScoresin interfaceClassifier<U>- Parameters:
instance- the individual instance.- Returns:
- A score for each class.
-
computeScore
Description copied from interface:ClassifierGets the score for an individual pattern in a certain category.- Specified by:
computeScorein interfaceClassifier<U>- Parameters:
instance- the pattern.category- the class.- Returns:
- the score.
-
classify
Description copied from interface:ClassifierObtains the most likely class for a certain instance.- Specified by:
classifyin interfaceClassifier<U>- Parameters:
instance- the individual instance.- Returns:
- The most likely class.
-