Class SparseLogisticRegression.Binomial
java.lang.Object
smile.classification.AbstractClassifier<SparseArray>
smile.classification.SparseLogisticRegression
smile.classification.SparseLogisticRegression.Binomial
- All Implemented Interfaces:
Serializable, ToDoubleFunction<SparseArray>, ToIntFunction<SparseArray>, Classifier<SparseArray>
- Enclosing class:
SparseLogisticRegression
Binomial logistic regression. The dependent variable is nominal of two levels.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class SparseLogisticRegression
SparseLogisticRegression.Binomial, SparseLogisticRegression.MultinomialNested classes/interfaces inherited from interface Classifier
Classifier.Trainer<T,M> -
Field Summary
Fields inherited from class AbstractClassifier
classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[]Returns an array of size (p+1) containing the linear weights of binary logistic regression, where p is the dimension of feature vectors.intPredicts the class label of an instance.intpredict(SparseArray x, double[] posteriori) Predicts the class label of an instance and also calculate a posteriori probabilities.doublescore(SparseArray x) The raw prediction score.voidupdate(SparseArray x, int y) Online update the classifier with a new training instance.Methods inherited from class SparseLogisticRegression
AIC, binomial, binomial, fit, fit, fit, getLearningRate, loglikelihood, multinomial, multinomial, online, setLearningRate, softMethods inherited from class AbstractClassifier
classes, numClassesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Classifier
applyAsDouble, applyAsInt, predict, predict, predict, predict, predict, predict, update, update
-
Constructor Details
-
Binomial
Constructor.- Parameters:
w- the weights.L- the log-likelihood of learned model.lambda-lambda > 0gives 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 an array of size (p+1) containing the linear weights of binary logistic regression, where p is the dimension of feature vectors. The last element is the weight of bias.- Returns:
- the linear weights.
-
score
Description copied from interface:ClassifierThe raw prediction score.- Parameters:
x- the instance to be classified.- Returns:
- the raw prediction score.
-
predict
Description copied from interface:ClassifierPredicts the class label of an instance.- Parameters:
x- the instance to be classified.- Returns:
- the predicted class label.
-
predict
Description copied from interface:ClassifierPredicts 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:ClassifierOnline 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.
-