public class LogisticRegression extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
LogisticRegression.Builder |
Constructor and Description |
---|
LogisticRegression(org.jblas.DoubleMatrix input,
org.jblas.DoubleMatrix labels,
int nIn,
int nOut) |
LogisticRegression(org.jblas.DoubleMatrix input,
int nIn,
int nOut) |
LogisticRegression(int nIn,
int nOut) |
Modifier and Type | Method and Description |
---|---|
protected LogisticRegression |
clone() |
org.jblas.DoubleMatrix |
getB() |
LogisticRegressionGradient |
getGradient(double lr)
Gets the gradient from one training iteration
|
org.jblas.DoubleMatrix |
getInput() |
double |
getL2() |
org.jblas.DoubleMatrix |
getLabels() |
int |
getnIn() |
int |
getnOut() |
org.jblas.DoubleMatrix |
getW() |
boolean |
isUseRegularization() |
void |
merge(LogisticRegression l,
int batchSize)
Averages the given logistic regression
from a mini batch in to this one
|
double |
negativeLogLikelihood()
Objective function: minimize negative log likelihood
|
org.jblas.DoubleMatrix |
predict(org.jblas.DoubleMatrix x)
Classify input
|
void |
setB(org.jblas.DoubleMatrix b) |
void |
setInput(org.jblas.DoubleMatrix input) |
void |
setL2(double l2) |
void |
setLabels(org.jblas.DoubleMatrix labels) |
void |
setnIn(int nIn) |
void |
setnOut(int nOut) |
void |
setUseRegularization(boolean useRegularization) |
void |
setW(org.jblas.DoubleMatrix w) |
void |
train(double lr)
Train with current input and labels
with the given learning rate
|
void |
train(org.jblas.DoubleMatrix x,
double lr)
Train with the given input
and the currently set labels
|
void |
train(org.jblas.DoubleMatrix x,
org.jblas.DoubleMatrix y,
double lr)
Train on the given inputs and labels.
|
void |
trainTillConvergence(double learningRate,
int numEpochs)
Run conjugate gradient
|
void |
trainTillConvergence(org.jblas.DoubleMatrix x,
org.jblas.DoubleMatrix y,
double learningRate,
int epochs)
Run conjugate gradient with the given x and y
|
public LogisticRegression(org.jblas.DoubleMatrix input, org.jblas.DoubleMatrix labels, int nIn, int nOut)
public LogisticRegression(org.jblas.DoubleMatrix input, int nIn, int nOut)
public LogisticRegression(int nIn, int nOut)
public void train(double lr)
lr
- the learning rate to usepublic void train(org.jblas.DoubleMatrix x, double lr)
x
- the input to uselr
- the learning rate to usepublic void trainTillConvergence(org.jblas.DoubleMatrix x, org.jblas.DoubleMatrix y, double learningRate, int epochs)
x
- the input to usey
- the labels to uselearningRate
- epochs
- public void trainTillConvergence(double learningRate, int numEpochs)
learningRate
- the learning rate to train withnumEpochs
- the number of epochspublic void merge(LogisticRegression l, int batchSize)
l
- the logistic regression to average in to this onebatchSize
- the batch sizepublic double negativeLogLikelihood()
public void train(org.jblas.DoubleMatrix x, org.jblas.DoubleMatrix y, double lr)
x
- the inputs to train ony
- the labels to train onlr
- the learning rateprotected LogisticRegression clone()
public LogisticRegressionGradient getGradient(double lr)
lr
- the learning rate to use for trainingpublic org.jblas.DoubleMatrix predict(org.jblas.DoubleMatrix x)
x
- the input (can either be a matrix or vector)
If it's a matrix, each row is considered an example
and associated rows are classified accordingly.
Each row will be the likelihood of a label given that examplepublic int getnIn()
public void setnIn(int nIn)
public int getnOut()
public void setnOut(int nOut)
public org.jblas.DoubleMatrix getInput()
public void setInput(org.jblas.DoubleMatrix input)
public org.jblas.DoubleMatrix getLabels()
public void setLabels(org.jblas.DoubleMatrix labels)
public org.jblas.DoubleMatrix getW()
public void setW(org.jblas.DoubleMatrix w)
public org.jblas.DoubleMatrix getB()
public void setB(org.jblas.DoubleMatrix b)
public double getL2()
public void setL2(double l2)
public boolean isUseRegularization()
public void setUseRegularization(boolean useRegularization)
Copyright © 2014. All Rights Reserved.