org.apache.spark.ml.classification
Class LogisticAggregator

Object
  extended by org.apache.spark.ml.classification.LogisticAggregator
All Implemented Interfaces:
java.io.Serializable

public class LogisticAggregator
extends Object
implements scala.Serializable

LogisticAggregator computes the gradient and loss for binary logistic loss function, as used in binary classification for samples in sparse or dense vector in a online fashion.

Note that multinomial logistic loss is not supported yet!

Two LogisticAggregator can be merged together to have a summary of loss and gradient of the corresponding joint dataset.

param: weights The weights/coefficients corresponding to the features. param: numClasses the number of possible outcomes for k classes classification problem in Multinomial Logistic Regression. param: fitIntercept Whether to fit an intercept term. param: featuresStd The standard deviation values of the features. param: featuresMean The mean values of the features.

See Also:
Serialized Form

Constructor Summary
LogisticAggregator(Vector weights, int numClasses, boolean fitIntercept, double[] featuresStd, double[] featuresMean)
           
 
Method Summary
 LogisticAggregator add(double label, Vector data)
          Add a new training data to this LogisticAggregator, and update the loss and gradient of the objective function.
 long count()
           
 Vector gradient()
           
 double loss()
           
 LogisticAggregator merge(LogisticAggregator other)
          Merge another LogisticAggregator, and update the loss and gradient of the objective function.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogisticAggregator

public LogisticAggregator(Vector weights,
                          int numClasses,
                          boolean fitIntercept,
                          double[] featuresStd,
                          double[] featuresMean)
Method Detail

add

public LogisticAggregator add(double label,
                              Vector data)
Add a new training data to this LogisticAggregator, and update the loss and gradient of the objective function.

Parameters:
label - The label for this data point.
data - The features for one data point in dense/sparse vector format to be added into this aggregator.
Returns:
This LogisticAggregator object.

merge

public LogisticAggregator merge(LogisticAggregator other)
Merge another LogisticAggregator, and update the loss and gradient of the objective function. (Note that it's in place merging; as a result, this object will be modified.)

Parameters:
other - The other LogisticAggregator to be merged.
Returns:
This LogisticAggregator object.

count

public long count()

loss

public double loss()

gradient

public Vector gradient()