Package edu.pitt.csb.mgm
Class Mgm
java.lang.Object
edu.pitt.csb.mgm.ConvexProximal
edu.pitt.csb.mgm.Mgm
- All Implemented Interfaces:
IGraphSearch
Implementation of Lee and Hastie's (2012) pseudolikelihood method for learning Mixed Gaussian-Categorical Graphical
Models Created by ajsedgewick on 7/15/15.
- Version:
- $Id: $Id
- Author:
- josephramsey
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncern.colt.matrix.DoubleMatrix2DConverts MGM to matrix of doubles.static cern.colt.matrix.DoubleMatrix1Dflatten(cern.colt.matrix.DoubleMatrix2D m) flatten.longReturn time of execution for learning.Converts MGM object to Graph object with edges if edge parameters are non-zero.voidlearn(double epsilon, int iterLimit) Learn MGM traditional way with objective function tolerance.voidlearnEdges(int iterLimit) Learn MGM using edge convergence using default 3 iterations of no edge changes.voidlearnEdges(int iterLimit, int edgeChangeTol) Learn MGM using edge convergence using edgeChangeTol (see ProximalGradient for documentation).static voidmain.doublenonSmooth(double t, cern.colt.matrix.DoubleMatrix1D X, cern.colt.matrix.DoubleMatrix1D pX) Calculates the non-smooth value for a given parameter and input vectors.doublenonSmoothValue(cern.colt.matrix.DoubleMatrix1D parIn) Calculates the non-smooth value for the given input vector.cern.colt.matrix.DoubleMatrix1DproximalOperator(double t, cern.colt.matrix.DoubleMatrix1D X) Applies proximal operator on the given input vector with a positive parameter.search()Simple search command for GraphSearch implementation.voidsetParams(Mgm.MGMParams newParams) Setter for the fieldparams.doublesmooth(cern.colt.matrix.DoubleMatrix1D parIn, cern.colt.matrix.DoubleMatrix1D gradOutVec) Smooth method calculates the smooth loss and gradient given input parameters.cern.colt.matrix.DoubleMatrix1DsmoothGradient(cern.colt.matrix.DoubleMatrix1D parIn) Calculates the smooth gradient for a given input vector.doublesmoothValue(cern.colt.matrix.DoubleMatrix1D parIn) Calculate the smooth value of the given input vector.static cern.colt.matrix.DoubleMatrix2DupperTri(cern.colt.matrix.DoubleMatrix2D mat, int di) upperTri.
-
Constructor Details
-
Mgm
public Mgm(cern.colt.matrix.DoubleMatrix2D x, cern.colt.matrix.DoubleMatrix2D y, List<Node> variables, int[] l, double[] lambda) Constructor for Mgm.
- Parameters:
x- aDoubleMatrix2Dobjecty- aDoubleMatrix2Dobjectvariables- aListobjectl- an array ofintobjectslambda- an array ofdoubleobjects
-
Mgm
Constructor for Mgm.
- Parameters:
ds- aDataSetobjectlambda- an array ofdoubleobjects
-
-
Method Details
-
flatten
public static cern.colt.matrix.DoubleMatrix1D flatten(cern.colt.matrix.DoubleMatrix2D m) flatten.
- Parameters:
m- aDoubleMatrix2Dobject- Returns:
- a
DoubleMatrix1Dobject
-
upperTri
public static cern.colt.matrix.DoubleMatrix2D upperTri(cern.colt.matrix.DoubleMatrix2D mat, int di) upperTri.
- Parameters:
mat- aDoubleMatrix2Dobjectdi- a int- Returns:
- a
DoubleMatrix2Dobject
-
main
main.
- Parameters:
args- an array ofStringobjects
-
setParams
Setter for the field
params.- Parameters:
newParams- aMgm.MGMParamsobject
-
smoothValue
public double smoothValue(cern.colt.matrix.DoubleMatrix1D parIn) Calculate the smooth value of the given input vector.- Parameters:
parIn- The input vector.- Returns:
- The smooth value.
-
smooth
public double smooth(cern.colt.matrix.DoubleMatrix1D parIn, cern.colt.matrix.DoubleMatrix1D gradOutVec) Smooth method calculates the smooth loss and gradient given input parameters.- Overrides:
smoothin classConvexProximal- Parameters:
parIn- input VectorgradOutVec- gradient of g(X)- Returns:
- the smooth loss
-
nonSmoothValue
public double nonSmoothValue(cern.colt.matrix.DoubleMatrix1D parIn) Calculates the non-smooth value for the given input vector.- Parameters:
parIn- the input vector- Returns:
- the non-smooth value
-
smoothGradient
public cern.colt.matrix.DoubleMatrix1D smoothGradient(cern.colt.matrix.DoubleMatrix1D parIn) Calculates the smooth gradient for a given input vector.- Parameters:
parIn- the input vector- Returns:
- the smooth gradient
-
proximalOperator
public cern.colt.matrix.DoubleMatrix1D proximalOperator(double t, cern.colt.matrix.DoubleMatrix1D X) Applies proximal operator on the given input vector with a positive parameter.- Parameters:
t- the positive parameter for proximal operatorX- the input vector- Returns:
- the result of applying proximal operator on the input vector
- Throws:
IllegalArgumentException- if t is not positive
-
nonSmooth
public double nonSmooth(double t, cern.colt.matrix.DoubleMatrix1D X, cern.colt.matrix.DoubleMatrix1D pX) Calculates the non-smooth value for a given parameter and input vectors.- Overrides:
nonSmoothin classConvexProximal- Parameters:
t- the positive parameter for the prox operatorX- the input vectorpX- the vector solution to prox_t(X)- Returns:
- the non-smooth value
-
learn
public void learn(double epsilon, int iterLimit) Learn MGM traditional way with objective function tolerance. Recommended for inference applications that need accurate pseudolikelihood- Parameters:
epsilon- tolerance in change of objective functioniterLimit- iteration limit
-
learnEdges
public void learnEdges(int iterLimit) Learn MGM using edge convergence using default 3 iterations of no edge changes. Recommended when we only care about edge existence.- Parameters:
iterLimit- a int
-
learnEdges
public void learnEdges(int iterLimit, int edgeChangeTol) Learn MGM using edge convergence using edgeChangeTol (see ProximalGradient for documentation). Recommended when we only care about edge existence.- Parameters:
iterLimit- a intedgeChangeTol- a int
-
graphFromMGM
Converts MGM object to Graph object with edges if edge parameters are non-zero. Loses all edge param information- Returns:
- a
Graphobject
-
adjMatFromMGM
public cern.colt.matrix.DoubleMatrix2D adjMatFromMGM()Converts MGM to matrix of doubles. uses 2-norm to combine c-d edge parameters into single value and f-norm for d-d edge parameters.- Returns:
- a
DoubleMatrix2Dobject
-
search
Simple search command for GraphSearch implementation. Uses default edge convergence, 1000 iter limit.- Specified by:
searchin interfaceIGraphSearch- Returns:
- a
Graphobject
-
getElapsedTime
public long getElapsedTime()Return time of execution for learning.- Returns:
- a long
-