Interface LogisticRegressionParams
- All Superinterfaces:
ClassifierParams
,HasAggregationDepth
,HasElasticNetParam
,HasFeaturesCol
,HasFitIntercept
,HasLabelCol
,HasMaxBlockSizeInMB
,HasMaxIter
,HasPredictionCol
,HasProbabilityCol
,HasRawPredictionCol
,HasRegParam
,HasStandardization
,HasThreshold
,HasThresholds
,HasTol
,HasWeightCol
,Identifiable
,Params
,PredictorParams
,ProbabilisticClassifierParams
,Serializable
,scala.Serializable
- All Known Implementing Classes:
LogisticRegression
,LogisticRegressionModel
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Ifthreshold
andthresholds
are both set, ensures they are consistent.family()
Param for the name of family which is a description of the label distribution to be used in the model.double
Get threshold for binary classification.double[]
Get thresholds for binary or multiclass classification.The lower bounds on coefficients if fitting under bound constrained optimization.The lower bounds on intercepts if fitting under bound constrained optimization.setThreshold
(double value) Set threshold in binary classification, in range [0, 1].setThresholds
(double[] value) Set thresholds in multiclass (or binary) classification to adjust the probability of predicting each class.The upper bounds on coefficients if fitting under bound constrained optimization.The upper bounds on intercepts if fitting under bound constrained optimization.boolean
validateAndTransformSchema
(StructType schema, boolean fitting, DataType featuresDataType) Validates and transforms the input schema with the provided param map.Methods inherited from interface org.apache.spark.ml.param.shared.HasAggregationDepth
aggregationDepth, getAggregationDepth
Methods inherited from interface org.apache.spark.ml.param.shared.HasElasticNetParam
elasticNetParam, getElasticNetParam
Methods inherited from interface org.apache.spark.ml.param.shared.HasFeaturesCol
featuresCol, getFeaturesCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasFitIntercept
fitIntercept, getFitIntercept
Methods inherited from interface org.apache.spark.ml.param.shared.HasLabelCol
getLabelCol, labelCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasMaxBlockSizeInMB
getMaxBlockSizeInMB, maxBlockSizeInMB
Methods inherited from interface org.apache.spark.ml.param.shared.HasMaxIter
getMaxIter, maxIter
Methods inherited from interface org.apache.spark.ml.param.shared.HasPredictionCol
getPredictionCol, predictionCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasProbabilityCol
getProbabilityCol, probabilityCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasRawPredictionCol
getRawPredictionCol, rawPredictionCol
Methods inherited from interface org.apache.spark.ml.param.shared.HasRegParam
getRegParam, regParam
Methods inherited from interface org.apache.spark.ml.param.shared.HasStandardization
getStandardization, standardization
Methods inherited from interface org.apache.spark.ml.param.shared.HasThreshold
threshold
Methods inherited from interface org.apache.spark.ml.param.shared.HasThresholds
thresholds
Methods inherited from interface org.apache.spark.ml.param.shared.HasWeightCol
getWeightCol, weightCol
Methods inherited from interface org.apache.spark.ml.util.Identifiable
toString, uid
Methods inherited from interface org.apache.spark.ml.param.Params
clear, copy, copyValues, defaultCopy, defaultParamMap, explainParam, explainParams, extractParamMap, extractParamMap, get, getDefault, getOrDefault, getParam, hasDefault, hasParam, isDefined, isSet, onParamChange, paramMap, params, set, set, set, setDefault, setDefault, shouldOwn
-
Method Details
-
checkThresholdConsistency
void checkThresholdConsistency()Ifthreshold
andthresholds
are both set, ensures they are consistent.- Throws:
IllegalArgumentException
- ifthreshold
andthresholds
are not equivalent
-
family
Param for the name of family which is a description of the label distribution to be used in the model. Supported options: - "auto": Automatically select the family based on the number of classes: If numClasses == 1 || numClasses == 2, set to "binomial". Else, set to "multinomial" - "binomial": Binary logistic regression with pivoting. - "multinomial": Multinomial logistic (softmax) regression without pivoting. Default is "auto".- Returns:
- (undocumented)
-
getFamily
String getFamily() -
getLowerBoundsOnCoefficients
Matrix getLowerBoundsOnCoefficients() -
getLowerBoundsOnIntercepts
Vector getLowerBoundsOnIntercepts() -
getThreshold
double getThreshold()Get threshold for binary classification.If
thresholds
is set with length 2 (i.e., binary classification), this returns the equivalent threshold:
. Otherwise, returns `threshold` if set, or its default value if unset. @group getParam @throws IllegalArgumentException if `thresholds` is set to an array of length other than 2.1 / (1 + thresholds(0) / thresholds(1))
- Specified by:
getThreshold
in interfaceHasThreshold
- Returns:
- (undocumented)
-
getThresholds
double[] getThresholds()Get thresholds for binary or multiclass classification.If
thresholds
is set, return its value. Otherwise, ifthreshold
is set, return the equivalent thresholds for binary classification: (1-threshold, threshold). If neither are set, throw an exception.- Specified by:
getThresholds
in interfaceHasThresholds
- Returns:
- (undocumented)
-
getUpperBoundsOnCoefficients
Matrix getUpperBoundsOnCoefficients() -
getUpperBoundsOnIntercepts
Vector getUpperBoundsOnIntercepts() -
lowerBoundsOnCoefficients
The lower bounds on coefficients if fitting under bound constrained optimization. The bound matrix must be compatible with the shape (1, number of features) for binomial regression, or (number of classes, number of features) for multinomial regression. Otherwise, it throws exception. Default is none.- Returns:
- (undocumented)
-
lowerBoundsOnIntercepts
The lower bounds on intercepts if fitting under bound constrained optimization. The bounds vector size must be equal to 1 for binomial regression, or the number of classes for multinomial regression. Otherwise, it throws exception. Default is none.- Returns:
- (undocumented)
-
setThreshold
Set threshold in binary classification, in range [0, 1].If the estimated probability of class label 1 is greater than threshold, then predict 1, else 0. A high threshold encourages the model to predict 0 more often; a low threshold encourages the model to predict 1 more often.
Note: Calling this with threshold p is equivalent to calling
setThresholds(Array(1-p, p))
. WhensetThreshold()
is called, any user-set value forthresholds
will be cleared. If boththreshold
andthresholds
are set in a ParamMap, then they must be equivalent.Default is 0.5.
- Parameters:
value
- (undocumented)- Returns:
- (undocumented)
-
setThresholds
Set thresholds in multiclass (or binary) classification to adjust the probability of predicting each class. Array must have length equal to the number of classes, with values greater than 0, excepting that at most one value may be 0. The class with largest value p/t is predicted, where p is the original probability of that class and t is the class's threshold.Note: When
setThresholds()
is called, any user-set value forthreshold
will be cleared. If boththreshold
andthresholds
are set in a ParamMap, then they must be equivalent.- Parameters:
value
- (undocumented)- Returns:
- (undocumented)
-
upperBoundsOnCoefficients
The upper bounds on coefficients if fitting under bound constrained optimization. The bound matrix must be compatible with the shape (1, number of features) for binomial regression, or (number of classes, number of features) for multinomial regression. Otherwise, it throws exception. Default is none.- Returns:
- (undocumented)
-
upperBoundsOnIntercepts
The upper bounds on intercepts if fitting under bound constrained optimization. The bound vector size must be equal to 1 for binomial regression, or the number of classes for multinomial regression. Otherwise, it throws exception. Default is none.- Returns:
- (undocumented)
-
usingBoundConstrainedOptimization
boolean usingBoundConstrainedOptimization() -
validateAndTransformSchema
StructType validateAndTransformSchema(StructType schema, boolean fitting, DataType featuresDataType) Description copied from interface:PredictorParams
Validates and transforms the input schema with the provided param map.- Specified by:
validateAndTransformSchema
in interfaceClassifierParams
- Specified by:
validateAndTransformSchema
in interfacePredictorParams
- Specified by:
validateAndTransformSchema
in interfaceProbabilisticClassifierParams
- Parameters:
schema
- input schemafitting
- whether this is in fittingfeaturesDataType
- SQL DataType for FeaturesType. E.g.,VectorUDT
for vector features.- Returns:
- output schema
-