Package smile.classification
Class SparseLogisticRegression.Multinomial
java.lang.Object
smile.classification.AbstractClassifier<SparseArray>
smile.classification.SparseLogisticRegression
smile.classification.SparseLogisticRegression.Multinomial
- All Implemented Interfaces:
Serializable
,ToDoubleFunction<SparseArray>
,ToIntFunction<SparseArray>
,Classifier<SparseArray>
- Enclosing class:
SparseLogisticRegression
Multinomial logistic regression. The dependent variable is nominal with more than two levels.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class smile.classification.SparseLogisticRegression
SparseLogisticRegression.Binomial, SparseLogisticRegression.Multinomial
Nested classes/interfaces inherited from interface smile.classification.Classifier
Classifier.Trainer<T,
M extends Classifier<T>> -
Field Summary
Fields inherited from class smile.classification.AbstractClassifier
classes
-
Constructor Summary
ConstructorDescriptionMultinomial
(double[][] w, double L, double lambda, IntSet labels) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble[][]
Returns a 2d-array of size (k-1) x (p+1), containing the linear weights of multi-class logistic regression, where k is the number of classes and p is the dimension of feature vectors.int
Predicts the class label of an instance.int
predict
(SparseArray x, double[] posteriori) Predicts the class label of an instance and also calculate a posteriori probabilities.void
update
(SparseArray x, int y) Online update the classifier with a new training instance.Methods inherited from class smile.classification.SparseLogisticRegression
AIC, binomial, binomial, binomial, fit, fit, fit, getLearningRate, loglikelihood, multinomial, multinomial, multinomial, online, setLearningRate, soft
Methods inherited from class smile.classification.AbstractClassifier
classes, numClasses
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface smile.classification.Classifier
applyAsDouble, applyAsInt, predict, predict, predict, predict, predict, predict, score, update, update
-
Constructor Details
-
Multinomial
Constructor.- Parameters:
w
- the weights.L
- the log-likelihood of learned model.lambda
-lambda > 0
gives a "regularized" estimate of linear weights which often has superior generalization performance, especially when the dimensionality is high.labels
- the class label encoder.
-
-
Method Details
-
coefficients
public double[][] coefficients()Returns a 2d-array of size (k-1) x (p+1), containing the linear weights of multi-class logistic regression, where k is the number of classes and p is the dimension of feature vectors. The last element of each row is the weight of bias.- Returns:
- the linear weights.
-
predict
Description copied from interface:Classifier
Predicts the class label of an instance.- Parameters:
x
- the instance to be classified.- Returns:
- the predicted class label.
-
predict
Description copied from interface:Classifier
Predicts the class label of an instance and also calculate a posteriori probabilities. Classifiers may NOT support this method since not all classification algorithms are able to calculate such a posteriori probabilities.- Parameters:
x
- an instance to be classified.posteriori
- a posteriori probabilities on output.- Returns:
- the predicted class label
-
update
Description copied from interface:Classifier
Online update the classifier with a new training instance. In general, this method may be NOT multi-thread safe.- Parameters:
x
- the training instance.y
- the training label.
-