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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncern.colt.matrix.DoubleMatrix2D
Converts MGM to matrix of doubles.static cern.colt.matrix.DoubleMatrix1D
flatten
(cern.colt.matrix.DoubleMatrix2D m) long
Return time of execution for learning.Converts MGM object to Graph object with edges if edge parameters are non-zero.void
learn
(double epsilon, int iterLimit) Learn MGM traditional way with objective function tolerance.void
learnEdges
(int iterLimit) Learn MGM using edge convergence using default 3 iterations of no edge changes.void
learnEdges
(int iterLimit, int edgeChangeTol) Learn MGM using edge convergence using edgeChangeTol (see ProximalGradient for documentation).static void
double
nonSmooth
(double t, cern.colt.matrix.DoubleMatrix1D X, cern.colt.matrix.DoubleMatrix1D pX) Calculates penalty term and proximal operator at the same time for speeddouble
nonSmoothValue
(cern.colt.matrix.DoubleMatrix1D parIn) Calculates penalty term of objective functioncern.colt.matrix.DoubleMatrix1D
proximalOperator
(double t, cern.colt.matrix.DoubleMatrix1D X) A proximal operator for the MGMsearch()
Simple search command for GraphSearch implementation.void
setParams
(Mgm.MGMParams newParams) double
smooth
(cern.colt.matrix.DoubleMatrix1D parIn, cern.colt.matrix.DoubleMatrix1D gradOutVec) non-penalized -log(pseudolikelihood) this is the smooth function g(x) in prox gradient this overloaded version calculates both nll and the smooth gradient at the same time any value in gradOut will be replaced by the new calculationscern.colt.matrix.DoubleMatrix1D
smoothGradient
(cern.colt.matrix.DoubleMatrix1D parIn) Gradient of the pseudolikelihooddouble
smoothValue
(cern.colt.matrix.DoubleMatrix1D parIn) non-penalized -log(pseudolikelihood) this is the smooth function g(x) in prox gradientstatic cern.colt.matrix.DoubleMatrix2D
upperTri
(cern.colt.matrix.DoubleMatrix2D mat, int di)
-
Constructor Details
-
Mgm
-
Mgm
-
-
Method Details
-
flatten
public static cern.colt.matrix.DoubleMatrix1D flatten(cern.colt.matrix.DoubleMatrix2D m) -
upperTri
public static cern.colt.matrix.DoubleMatrix2D upperTri(cern.colt.matrix.DoubleMatrix2D mat, int di) -
main
-
setParams
-
smoothValue
public double smoothValue(cern.colt.matrix.DoubleMatrix1D parIn) non-penalized -log(pseudolikelihood) this is the smooth function g(x) in prox gradient- Parameters:
parIn
-- Returns:
-
smooth
public double smooth(cern.colt.matrix.DoubleMatrix1D parIn, cern.colt.matrix.DoubleMatrix1D gradOutVec) non-penalized -log(pseudolikelihood) this is the smooth function g(x) in prox gradient this overloaded version calculates both nll and the smooth gradient at the same time any value in gradOut will be replaced by the new calculations- Overrides:
smooth
in classConvexProximal
- Parameters:
parIn
-gradOutVec
-- Returns:
-
nonSmoothValue
public double nonSmoothValue(cern.colt.matrix.DoubleMatrix1D parIn) Calculates penalty term of objective function- Parameters:
parIn
-- Returns:
-
smoothGradient
public cern.colt.matrix.DoubleMatrix1D smoothGradient(cern.colt.matrix.DoubleMatrix1D parIn) Gradient of the pseudolikelihood- Parameters:
parIn
-- Returns:
-
proximalOperator
public cern.colt.matrix.DoubleMatrix1D proximalOperator(double t, cern.colt.matrix.DoubleMatrix1D X) A proximal operator for the MGM- Parameters:
t
- parameter for operator, must be positiveX
- input vector to operator- Returns:
- output vector, same dimension as X
-
nonSmooth
public double nonSmooth(double t, cern.colt.matrix.DoubleMatrix1D X, cern.colt.matrix.DoubleMatrix1D pX) Calculates penalty term and proximal operator at the same time for speed- Overrides:
nonSmooth
in classConvexProximal
- Parameters:
t
- proximal operator parameterX
- inputpX
- prox operator solution- Returns:
- value of penalty term
-
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
-
-
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
-edgeChangeTol
-
-
graphFromMGM
Converts MGM object to Graph object with edges if edge parameters are non-zero. Loses all edge param information- Returns:
-
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:
-
search
Simple search command for GraphSearch implementation. Uses default edge convergence, 1000 iter limit.- Specified by:
search
in interfaceIGraphSearch
- Returns:
-
getElapsedTime
public long getElapsedTime()Return time of execution for learning.- Returns:
-