public final class ComputationState
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ComputationState.GLMSubsetGinfo
This method will grab a subset of the gradient for each multinomial class.
|
static class |
ComputationState.GramGrad |
static class |
ComputationState.GramXY
Cached state of COD (with covariate updates) solver.
|
Modifier and Type | Field and Description |
---|---|
DataInfo[] |
_activeDataMultinomial |
ConstrainedGLMUtils.ConstraintGLMStates |
_csGLMState |
boolean |
_lsNeeded |
boolean |
_noReg |
GLMModel.GLMParameters |
_parms |
static double |
EPS_CS |
static double |
EPS_CS_SQUARE |
Constructor and Description |
---|
ComputationState(water.Job job,
GLMModel.GLMParameters parms,
DataInfo dinfo,
GLM.BetaConstraint bc,
GLM.BetaInfo bi) |
ComputationState(water.Job job,
GLMModel.GLMParameters parms,
DataInfo dinfo,
GLM.BetaConstraint bc,
GLM.BetaInfo bi,
double[][][] penaltyMat,
int[][] gamColInd) |
Modifier and Type | Method and Description |
---|---|
GLM.BetaConstraint |
activeBC() |
DataInfo |
activeData() |
DataInfo |
activeDataMultinomial() |
DataInfo |
activeDataMultinomial(int c) |
static double |
addConstraintObj(double[] lambda,
ConstrainedGLMUtils.LinearConstraints[] constraints,
double ckHalf)
This method adds to objective function the contribution of
transpose(lambda)*constraint vector + ck/2*transpose(constraint vector)*constraint vector
|
void |
addOffset2Cols(int[] cols) |
double |
alpha() |
protected void |
applyStrongRules(double lambdaNew,
double lambdaOld)
Apply strong rules to filter out expected inactive (with zero coefficient) predictors.
|
protected int |
applyStrongRulesMultinomial_old(double lambdaNew,
double lambdaOld)
Apply strong rules to filter out expected inactive (with zero coefficient) predictors.
|
protected void |
applyStrongRulesMultinomial(double lambdaNew,
double lambdaOld)
Apply strong rules to filter out expected inactive (with zero coefficient) predictors.
|
double[] |
beta() |
double[] |
betaMultinomial() |
double[] |
betaMultinomial(int c,
double[] beta) |
double[] |
betaMultinomialFull(int c,
double[] beta) |
static ConstrainedGLMUtils.ConstraintsDerivatives[] |
calDerivatives(ConstrainedGLMUtils.LinearConstraints[] constraints,
java.util.List<java.lang.String> coefNames)
This methold will calculate the first derivative of h(beta).
|
static ConstrainedGLMUtils.ConstraintsGram[] |
calGram(ConstrainedGLMUtils.ConstraintsDerivatives[] derivativeEqual)
This method to calculate contribution of penalty to gram (d2H/dbidbj), refer to the doc Section VI.II
|
protected boolean |
checkKKTs() |
protected boolean |
checkKKTsMultinomial() |
protected ComputationState.GramGrad |
computeGram(double[] beta,
GLM.GLMGradientInfo gradientInfo)
This function calculates the following values:
1.
|
ComputationState.GramXY |
computeGram(double[] beta,
GLMModel.GLMParameters.Solver s) |
ComputationState.GramXY |
computeGramRCC(double[] beta,
GLMModel.GLMParameters.Solver s)
This method is used only for multinomial family.
|
protected ComputationState.GramXY |
computeNewGram(DataInfo activeData,
double[] beta,
GLMModel.GLMParameters.Solver s) |
static ConstrainedGLMUtils.ConstraintsGram |
constructGram(ConstrainedGLMUtils.ConstraintsDerivatives constDeriv)
This method is not called often.
|
boolean |
converged() |
double |
deviance() |
boolean |
dispersionEstimated() |
void |
dropActiveData() |
double[] |
expandBeta(double[] beta) |
static double[] |
expandToFullArray(double[] shortenArr,
int[] activeCols,
int _totalBetaLength,
int nclasses,
int betaLengthPerClass) |
static double[] |
extractSubRange(int N,
int c,
int[] ids,
double[] src)
This method will return a double array that is extracted from src (which includes active and non-active columns)
to only include active columns stated in ids.
|
static double[] |
formXY(double[][] fullGram,
double[] beta,
double[] grad) |
static int[] |
genActiveColsAllClass(int activeColsLen,
int numBetaPerClass,
int[] activeColsOrig,
int nclasses) |
int[] |
genActiveColsIndClass(int activeColsLen,
int numBetaPerClass,
int[] activeColsOrig,
int activeClass,
int nclasses) |
static ConstrainedGLMUtils.ConstraintsDerivatives |
genOneDerivative(ConstrainedGLMUtils.LinearConstraints oneConstraints,
java.util.List<java.lang.String> coeffNames)
Given a constraint, this method will calculate the first order derivative.
|
boolean |
getLambdaNull() |
GLM.GLMGradientInfo |
ginfo() |
ComputationState.GLMSubsetGinfo |
ginfoMultinomial(int c) |
ComputationState.GLMSubsetGinfo |
ginfoMultinomialRCC(int c) |
boolean |
ginfoNull() |
GLM.GLMGradientSolver |
gslvr() |
OptimizationUtils.GradientSolver |
gslvrMultinomial(int c) |
void |
initConstraintDerivatives(ConstrainedGLMUtils.LinearConstraints[] equalityConstraints,
ConstrainedGLMUtils.LinearConstraints[] lessThanEqualToConstraints,
java.util.List<java.lang.String> coeffNames)
This method calculates
1.
|
double |
l1pen() |
double |
l2pen() |
double |
lambda() |
double |
likelihood() |
double |
objective() |
double |
objective(double[] beta,
double likelihood) |
int[] |
removeCols(int[] cols) |
void |
resizeConstraintInfo(ConstrainedGLMUtils.LinearConstraints[] equalityConstraints,
ConstrainedGLMUtils.LinearConstraints[] lessThanEqualToConstraints) |
void |
setActiveClass(int activeClass) |
protected void |
setActiveDataMultinomialNull() |
protected void |
setActiveDataNull() |
protected void |
setAllIn(boolean val) |
void |
setAlpha(double alpha) |
void |
setBC(GLM.BetaConstraint bc) |
protected void |
setBeta(double[] beta) |
protected void |
setBetaDiff(double betaDiff) |
void |
setBetaMultinomial(int c,
double[] beta,
double[] bc) |
void |
setConstraintInfo(GLM.GLMGradientInfo gradientInfo,
ConstrainedGLMUtils.LinearConstraints[] equalityConstraints,
ConstrainedGLMUtils.LinearConstraints[] lessThanEqualToConstraints,
double[] lambdaEqual,
double[] lambdaLessThan) |
protected void |
setGinfo(GLM.GLMGradientInfo ginfo) |
void |
setgMax(double gmax) |
protected void |
setGradientErr(double gErr) |
protected void |
setGslvrNull() |
protected void |
setIter(int iteration) |
void |
setLambda(double lambda) |
void |
setLambdaMax(double lmax) |
protected void |
setLambdaSimple(double lambda) |
protected void |
setLikelihood(double llk) |
void |
setLinearConstraints(ConstrainedGLMUtils.LinearConstraints[] equalityC,
ConstrainedGLMUtils.LinearConstraints[] lessThanEqualToC,
boolean forBeta) |
void |
setZValues(double[] zValues,
boolean dispersionEstimated) |
double[] |
shrinkFullArray(double[] fullArray) |
java.lang.String |
toString() |
void |
updateConstraintInfo(ConstrainedGLMUtils.LinearConstraints[] equalityConstraints,
ConstrainedGLMUtils.LinearConstraints[] lessThanEqualToConstraints)
Any time when the glm coefficient changes, the constraints values will change and active constraints can be inactive
and vice versa.
|
void |
updateDerivativeActive(ConstrainedGLMUtils.ConstraintsDerivatives[] derivativesConst,
ConstrainedGLMUtils.ConstraintsGram[] gramConst,
ConstrainedGLMUtils.LinearConstraints[] constraints) |
protected double |
updateState(double[] beta,
double likelihood) |
double |
updateState(double[] beta,
GLM.GLMGradientInfo ginfo) |
double[] |
zValues() |
public static final double EPS_CS
public static final double EPS_CS_SQUARE
public final GLMModel.GLMParameters _parms
public boolean _noReg
public ConstrainedGLMUtils.ConstraintGLMStates _csGLMState
public boolean _lsNeeded
public DataInfo[] _activeDataMultinomial
public ComputationState(water.Job job, GLMModel.GLMParameters parms, DataInfo dinfo, GLM.BetaConstraint bc, GLM.BetaInfo bi)
public ComputationState(water.Job job, GLMModel.GLMParameters parms, DataInfo dinfo, GLM.BetaConstraint bc, GLM.BetaInfo bi, double[][][] penaltyMat, int[][] gamColInd)
public void initConstraintDerivatives(ConstrainedGLMUtils.LinearConstraints[] equalityConstraints, ConstrainedGLMUtils.LinearConstraints[] lessThanEqualToConstraints, java.util.List<java.lang.String> coeffNames)
public void updateConstraintInfo(ConstrainedGLMUtils.LinearConstraints[] equalityConstraints, ConstrainedGLMUtils.LinearConstraints[] lessThanEqualToConstraints)
public void updateDerivativeActive(ConstrainedGLMUtils.ConstraintsDerivatives[] derivativesConst, ConstrainedGLMUtils.ConstraintsGram[] gramConst, ConstrainedGLMUtils.LinearConstraints[] constraints)
public void resizeConstraintInfo(ConstrainedGLMUtils.LinearConstraints[] equalityConstraints, ConstrainedGLMUtils.LinearConstraints[] lessThanEqualToConstraints)
public void setZValues(double[] zValues, boolean dispersionEstimated)
public boolean getLambdaNull()
public GLM.GLMGradientSolver gslvr()
public double lambda()
public double alpha()
public double[] zValues()
public boolean dispersionEstimated()
public void setLambdaMax(double lmax)
public void setgMax(double gmax)
public void setAlpha(double alpha)
public void setLambda(double lambda)
public double[] beta()
public GLM.GLMGradientInfo ginfo()
public GLM.BetaConstraint activeBC()
public double likelihood()
public boolean ginfoNull()
public DataInfo activeData()
public DataInfo activeDataMultinomial()
public void dropActiveData()
public java.lang.String toString()
toString
in class java.lang.Object
public double l1pen()
public double l2pen()
protected void applyStrongRules(double lambdaNew, double lambdaOld)
public DataInfo activeDataMultinomial(int c)
public static double[] extractSubRange(int N, int c, int[] ids, double[] src)
N
- c
- ids
- src
- public double[] betaMultinomial()
public double[] betaMultinomial(int c, double[] beta)
public double[] betaMultinomialFull(int c, double[] beta)
public double[] shrinkFullArray(double[] fullArray)
public static double[] expandToFullArray(double[] shortenArr, int[] activeCols, int _totalBetaLength, int nclasses, int betaLengthPerClass)
public static int[] genActiveColsAllClass(int activeColsLen, int numBetaPerClass, int[] activeColsOrig, int nclasses)
public int[] genActiveColsIndClass(int activeColsLen, int numBetaPerClass, int[] activeColsOrig, int activeClass, int nclasses)
public ComputationState.GLMSubsetGinfo ginfoMultinomial(int c)
public ComputationState.GLMSubsetGinfo ginfoMultinomialRCC(int c)
public void setBC(GLM.BetaConstraint bc)
public void setLinearConstraints(ConstrainedGLMUtils.LinearConstraints[] equalityC, ConstrainedGLMUtils.LinearConstraints[] lessThanEqualToC, boolean forBeta)
public void setActiveClass(int activeClass)
public double deviance()
public OptimizationUtils.GradientSolver gslvrMultinomial(int c)
public void setBetaMultinomial(int c, double[] beta, double[] bc)
protected int applyStrongRulesMultinomial_old(double lambdaNew, double lambdaOld)
protected void applyStrongRulesMultinomial(double lambdaNew, double lambdaOld)
protected boolean checkKKTsMultinomial()
protected boolean checkKKTs()
public void addOffset2Cols(int[] cols)
public int[] removeCols(int[] cols)
public double objective()
public double objective(double[] beta, double likelihood)
public static ConstrainedGLMUtils.ConstraintsDerivatives[] calDerivatives(ConstrainedGLMUtils.LinearConstraints[] constraints, java.util.List<java.lang.String> coefNames)
public static ConstrainedGLMUtils.ConstraintsDerivatives genOneDerivative(ConstrainedGLMUtils.LinearConstraints oneConstraints, java.util.List<java.lang.String> coeffNames)
public static ConstrainedGLMUtils.ConstraintsGram[] calGram(ConstrainedGLMUtils.ConstraintsDerivatives[] derivativeEqual)
public static ConstrainedGLMUtils.ConstraintsGram constructGram(ConstrainedGLMUtils.ConstraintsDerivatives constDeriv)
protected double updateState(double[] beta, double likelihood)
public boolean converged()
public double updateState(double[] beta, GLM.GLMGradientInfo ginfo)
protected void setBetaDiff(double betaDiff)
protected void setGradientErr(double gErr)
protected void setGinfo(GLM.GLMGradientInfo ginfo)
protected void setBeta(double[] beta)
protected void setIter(int iteration)
protected void setLikelihood(double llk)
protected void setAllIn(boolean val)
protected void setGslvrNull()
protected void setActiveDataMultinomialNull()
protected void setActiveDataNull()
protected void setLambdaSimple(double lambda)
public double[] expandBeta(double[] beta)
protected ComputationState.GramXY computeNewGram(DataInfo activeData, double[] beta, GLMModel.GLMParameters.Solver s)
public ComputationState.GramXY computeGramRCC(double[] beta, GLMModel.GLMParameters.Solver s)
beta
- s
- protected ComputationState.GramGrad computeGram(double[] beta, GLM.GLMGradientInfo gradientInfo)
public static double addConstraintObj(double[] lambda, ConstrainedGLMUtils.LinearConstraints[] constraints, double ckHalf)
public static double[] formXY(double[][] fullGram, double[] beta, double[] grad)
public ComputationState.GramXY computeGram(double[] beta, GLMModel.GLMParameters.Solver s)
public void setConstraintInfo(GLM.GLMGradientInfo gradientInfo, ConstrainedGLMUtils.LinearConstraints[] equalityConstraints, ConstrainedGLMUtils.LinearConstraints[] lessThanEqualToConstraints, double[] lambdaEqual, double[] lambdaLessThan)