public class LogisticRegressionWithSGD extends GeneralizedLinearAlgorithm<LogisticRegressionModel> implements scala.Serializable
LogisticRegressionWithSGD.optimizer
.
NOTE: Labels used in Logistic Regression should be {0, 1, ..., k - 1}
for k classes multi-label classification problem.
Using LogisticRegressionWithLBFGS
is recommended over this.Constructor and Description |
---|
LogisticRegressionWithSGD()
Construct a LogisticRegression object with default parameters: {stepSize: 1.0,
numIterations: 100, regParm: 0.01, miniBatchFraction: 1.0}.
|
Modifier and Type | Method and Description |
---|---|
protected LogisticRegressionModel |
createModel(Vector weights,
double intercept)
Create a model given the weights and intercept
|
GradientDescent |
optimizer()
The optimizer to solve the problem.
|
static LogisticRegressionModel |
train(RDD<LabeledPoint> input,
int numIterations)
Train a logistic regression model given an RDD of (label, features) pairs.
|
static LogisticRegressionModel |
train(RDD<LabeledPoint> input,
int numIterations,
double stepSize)
Train a logistic regression model given an RDD of (label, features) pairs.
|
static LogisticRegressionModel |
train(RDD<LabeledPoint> input,
int numIterations,
double stepSize,
double miniBatchFraction)
Train a logistic regression model given an RDD of (label, features) pairs.
|
static LogisticRegressionModel |
train(RDD<LabeledPoint> input,
int numIterations,
double stepSize,
double miniBatchFraction,
Vector initialWeights)
Train a logistic regression model given an RDD of (label, features) pairs.
|
protected scala.collection.immutable.List<scala.Function1<RDD<LabeledPoint>,java.lang.Object>> |
validators() |
addIntercept, getNumFeatures, isAddIntercept, numFeatures, numOfLinearPredictor, run, run, setIntercept, setValidateData, validateData
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
public LogisticRegressionWithSGD()
public static LogisticRegressionModel train(RDD<LabeledPoint> input, int numIterations, double stepSize, double miniBatchFraction, Vector initialWeights)
miniBatchFraction
fraction of the data to calculate the gradient. The weights used in
gradient descent are initialized using the initial weights provided.
NOTE: Labels used in Logistic Regression should be {0, 1}
input
- RDD of (label, array of features) pairs.numIterations
- Number of iterations of gradient descent to run.stepSize
- Step size to be used for each iteration of gradient descent.miniBatchFraction
- Fraction of data to be used per iteration.initialWeights
- Initial set of weights to be used. Array should be equal in size to
the number of features in the data.public static LogisticRegressionModel train(RDD<LabeledPoint> input, int numIterations, double stepSize, double miniBatchFraction)
miniBatchFraction
fraction of the data to calculate the gradient.
NOTE: Labels used in Logistic Regression should be {0, 1}
input
- RDD of (label, array of features) pairs.numIterations
- Number of iterations of gradient descent to run.stepSize
- Step size to be used for each iteration of gradient descent.
miniBatchFraction
- Fraction of data to be used per iteration.public static LogisticRegressionModel train(RDD<LabeledPoint> input, int numIterations, double stepSize)
input
- RDD of (label, array of features) pairs.stepSize
- Step size to be used for each iteration of Gradient Descent.
numIterations
- Number of iterations of gradient descent to run.public static LogisticRegressionModel train(RDD<LabeledPoint> input, int numIterations)
input
- RDD of (label, array of features) pairs.numIterations
- Number of iterations of gradient descent to run.public GradientDescent optimizer()
GeneralizedLinearAlgorithm
optimizer
in class GeneralizedLinearAlgorithm<LogisticRegressionModel>
protected scala.collection.immutable.List<scala.Function1<RDD<LabeledPoint>,java.lang.Object>> validators()
validators
in class GeneralizedLinearAlgorithm<LogisticRegressionModel>
protected LogisticRegressionModel createModel(Vector weights, double intercept)
GeneralizedLinearAlgorithm
createModel
in class GeneralizedLinearAlgorithm<LogisticRegressionModel>
weights
- (undocumented)intercept
- (undocumented)