org.apache.spark.ml.classification
Class LogisticRegression

Object
  extended by org.apache.spark.ml.PipelineStage
      extended by org.apache.spark.ml.Estimator<M>
          extended by org.apache.spark.ml.Predictor<FeaturesType,E,M>
              extended by org.apache.spark.ml.classification.Classifier<FeaturesType,E,M>
                  extended by org.apache.spark.ml.classification.LogisticRegression
All Implemented Interfaces:
java.io.Serializable, Logging, Params

public class LogisticRegression
extends Classifier<FeaturesType,E,M>
implements Logging

:: Experimental :: Logistic regression. Currently, this class only supports binary classification.

See Also:
Serialized Form

Constructor Summary
LogisticRegression()
           
LogisticRegression(String uid)
           
 
Method Summary
 LogisticRegression copy(ParamMap extra)
          Creates a copy of this instance with the same UID and some extra params.
 LogisticRegression setElasticNetParam(double value)
          Set the ElasticNet mixing parameter.
 LogisticRegression setFitIntercept(boolean value)
          Whether to fit an intercept term.
 LogisticRegression setMaxIter(int value)
          Set the maximum number of iterations.
 E setProbabilityCol(String value)
           
 LogisticRegression setRegParam(double value)
          Set the regularization parameter.
 LogisticRegression setThreshold(double value)
           
 LogisticRegression setTol(double value)
          Set the convergence tolerance of iterations.
 String uid()
           
 StructType validateAndTransformSchema(StructType schema, boolean fitting, DataType featuresDataType)
           
 StructType validateAndTransformSchema(StructType schema, boolean fitting, DataType featuresDataType)
          Validates and transforms the input schema with the provided param map.
 
Methods inherited from class org.apache.spark.ml.classification.Classifier
setRawPredictionCol
 
Methods inherited from class org.apache.spark.ml.Predictor
fit, setFeaturesCol, setLabelCol, setPredictionCol, transformSchema
 
Methods inherited from class org.apache.spark.ml.Estimator
fit, fit, fit, fit
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.spark.Logging
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
 
Methods inherited from interface org.apache.spark.ml.param.Params
clear, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, paramMap, params, set, set, set, setDefault, setDefault, setDefault, shouldOwn, validateParams
 

Constructor Detail

LogisticRegression

public LogisticRegression(String uid)

LogisticRegression

public LogisticRegression()
Method Detail

uid

public String uid()

setRegParam

public LogisticRegression setRegParam(double value)
Set the regularization parameter. Default is 0.0.

Parameters:
value - (undocumented)
Returns:
(undocumented)

setElasticNetParam

public LogisticRegression setElasticNetParam(double value)
Set the ElasticNet mixing parameter. For alpha = 0, the penalty is an L2 penalty. For alpha = 1, it is an L1 penalty. For 0 < alpha < 1, the penalty is a combination of L1 and L2. Default is 0.0 which is an L2 penalty.

Parameters:
value - (undocumented)
Returns:
(undocumented)

setMaxIter

public LogisticRegression setMaxIter(int value)
Set the maximum number of iterations. Default is 100.

Parameters:
value - (undocumented)
Returns:
(undocumented)

setTol

public LogisticRegression setTol(double value)
Set the convergence tolerance of iterations. Smaller value will lead to higher accuracy with the cost of more iterations. Default is 1E-6.

Parameters:
value - (undocumented)
Returns:
(undocumented)

setFitIntercept

public LogisticRegression setFitIntercept(boolean value)
Whether to fit an intercept term. Default is true.

Parameters:
value - (undocumented)
Returns:
(undocumented)

setThreshold

public LogisticRegression setThreshold(double value)

copy

public LogisticRegression copy(ParamMap extra)
Description copied from interface: Params
Creates a copy of this instance with the same UID and some extra params. Subclasses should implement this method and set the return type properly.

Specified by:
copy in interface Params
Specified by:
copy in class Predictor<Vector,LogisticRegression,LogisticRegressionModel>
Parameters:
extra - (undocumented)
Returns:
(undocumented)
See Also:
defaultCopy()

validateAndTransformSchema

public StructType validateAndTransformSchema(StructType schema,
                                             boolean fitting,
                                             DataType featuresDataType)

setProbabilityCol

public E setProbabilityCol(String value)

validateAndTransformSchema

public StructType validateAndTransformSchema(StructType schema,
                                             boolean fitting,
                                             DataType featuresDataType)
Validates and transforms the input schema with the provided param map.

Parameters:
schema - input schema
fitting - whether this is in fitting
featuresDataType - SQL DataType for FeaturesType. E.g., VectorUDT for vector features.
Returns:
output schema