org.apache.spark.mllib.classification
Class LogisticRegressionModel

Object
  extended by org.apache.spark.mllib.regression.GeneralizedLinearModel
      extended by org.apache.spark.mllib.classification.LogisticRegressionModel
All Implemented Interfaces:
java.io.Serializable, ClassificationModel, PMMLExportable, Saveable

public class LogisticRegressionModel
extends GeneralizedLinearModel
implements ClassificationModel, scala.Serializable, Saveable, PMMLExportable

Classification model trained using Multinomial/Binary Logistic Regression.

param: weights Weights computed for every feature. param: intercept Intercept computed for this model. (Only used in Binary Logistic Regression. In Multinomial Logistic Regression, the intercepts will not be a single value, so the intercepts will be part of the weights.) param: numFeatures the dimension of the features. param: numClasses the number of possible outcomes for k classes classification problem in Multinomial Logistic Regression. By default, it is binary logistic regression so numClasses will be set to 2.

See Also:
Serialized Form

Constructor Summary
LogisticRegressionModel(Vector weights, double intercept)
          Constructs a LogisticRegressionModel with weights and intercept for binary classification.
LogisticRegressionModel(Vector weights, double intercept, int numFeatures, int numClasses)
           
 
Method Summary
 LogisticRegressionModel clearThreshold()
          :: Experimental :: Clears the threshold so that predict will output raw prediction scores.
 scala.Option<Object> getThreshold()
          :: Experimental :: Returns the threshold (if any) used for converting raw prediction scores into 0/1 predictions.
 double intercept()
           
static LogisticRegressionModel load(SparkContext sc, String path)
           
 int numClasses()
           
 int numFeatures()
           
 void save(SparkContext sc, String path)
          Save this model to the given path.
 LogisticRegressionModel setThreshold(double threshold)
          :: Experimental :: Sets the threshold that separates positive predictions from negative predictions in Binary Logistic Regression.
 String toString()
          Print a summary of the model.
 Vector weights()
           
 
Methods inherited from class org.apache.spark.mllib.regression.GeneralizedLinearModel
predict, predict
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.spark.mllib.classification.ClassificationModel
predict, predict, predict
 
Methods inherited from interface org.apache.spark.mllib.pmml.PMMLExportable
toPMML, toPMML, toPMML, toPMML, toPMML
 

Constructor Detail

LogisticRegressionModel

public LogisticRegressionModel(Vector weights,
                               double intercept,
                               int numFeatures,
                               int numClasses)

LogisticRegressionModel

public LogisticRegressionModel(Vector weights,
                               double intercept)
Constructs a LogisticRegressionModel with weights and intercept for binary classification.

Parameters:
weights - (undocumented)
intercept - (undocumented)
Method Detail

load

public static LogisticRegressionModel load(SparkContext sc,
                                           String path)

weights

public Vector weights()
Overrides:
weights in class GeneralizedLinearModel

intercept

public double intercept()
Overrides:
intercept in class GeneralizedLinearModel

numFeatures

public int numFeatures()

numClasses

public int numClasses()

setThreshold

public LogisticRegressionModel setThreshold(double threshold)
:: Experimental :: Sets the threshold that separates positive predictions from negative predictions in Binary Logistic Regression. An example with prediction score greater than or equal to this threshold is identified as an positive, and negative otherwise. The default value is 0.5. It is only used for binary classification.

Parameters:
threshold - (undocumented)
Returns:
(undocumented)

getThreshold

public scala.Option<Object> getThreshold()
:: Experimental :: Returns the threshold (if any) used for converting raw prediction scores into 0/1 predictions. It is only used for binary classification.

Returns:
(undocumented)

clearThreshold

public LogisticRegressionModel clearThreshold()
:: Experimental :: Clears the threshold so that predict will output raw prediction scores. It is only used for binary classification.

Returns:
(undocumented)

save

public void save(SparkContext sc,
                 String path)
Description copied from interface: Saveable
Save this model to the given path.

This saves: - human-readable (JSON) model metadata to path/metadata/ - Parquet formatted data to path/data/

The model may be loaded using Loader.load.

Specified by:
save in interface Saveable
Parameters:
sc - Spark context used to save model data.
path - Path specifying the directory in which to save this model. If the directory already exists, this method throws an exception.

toString

public String toString()
Description copied from class: GeneralizedLinearModel
Print a summary of the model.

Overrides:
toString in class GeneralizedLinearModel
Returns:
(undocumented)