public class LogisticRegressionModel extends GeneralizedLinearModel implements ClassificationModel, scala.Serializable, Saveable, PMMLExportable
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.
Constructor and Description |
---|
LogisticRegressionModel(Vector weights,
double intercept)
Constructs a
LogisticRegressionModel with weights and intercept for binary classification. |
LogisticRegressionModel(Vector weights,
double intercept,
int numFeatures,
int numClasses) |
Modifier and Type | Method and Description |
---|---|
LogisticRegressionModel |
clearThreshold()
:: Experimental ::
Clears the threshold so that
predict will output raw prediction scores. |
protected java.lang.String |
formatVersion()
Current version of model save/load format.
|
scala.Option<java.lang.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,
java.lang.String path) |
int |
numClasses() |
int |
numFeatures() |
protected double |
predictPoint(Vector dataMatrix,
Vector weightMatrix,
double intercept)
Predict the result given a data point and the weights learned.
|
void |
save(SparkContext sc,
java.lang.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.
|
java.lang.String |
toString()
Print a summary of the model.
|
Vector |
weights() |
predict, predict
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
predict, predict, predict
public LogisticRegressionModel(Vector weights, double intercept, int numFeatures, int numClasses)
public LogisticRegressionModel(Vector weights, double intercept)
LogisticRegressionModel
with weights and intercept for binary classification.weights
- (undocumented)intercept
- (undocumented)public static LogisticRegressionModel load(SparkContext sc, java.lang.String path)
public Vector weights()
weights
in class GeneralizedLinearModel
public double intercept()
intercept
in class GeneralizedLinearModel
public int numFeatures()
public int numClasses()
public LogisticRegressionModel setThreshold(double threshold)
threshold
- (undocumented)public scala.Option<java.lang.Object> getThreshold()
public LogisticRegressionModel clearThreshold()
predict
will output raw prediction scores.
It is only used for binary classification.protected double predictPoint(Vector dataMatrix, Vector weightMatrix, double intercept)
GeneralizedLinearModel
predictPoint
in class GeneralizedLinearModel
dataMatrix
- Row vector containing the features for this data pointweightMatrix
- Column vector containing the weights of the modelintercept
- Intercept of the model.public void save(SparkContext sc, java.lang.String path)
Saveable
This saves: - human-readable (JSON) model metadata to path/metadata/ - Parquet formatted data to path/data/
The model may be loaded using Loader.load
.
protected java.lang.String formatVersion()
Saveable
formatVersion
in interface Saveable
public java.lang.String toString()
GeneralizedLinearModel
toString
in class GeneralizedLinearModel