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.DoubleMatrix2D
Converts MGM to matrix of doubles.static cern.colt.matrix.DoubleMatrix1D
flatten
(cern.colt.matrix.DoubleMatrix2D m) flatten.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
main.double
nonSmooth
(double t, cern.colt.matrix.DoubleMatrix1D X, cern.colt.matrix.DoubleMatrix1D pX) Calculate value of h(X) and proxOperator of h(X) at the same time for efficiency reasons.double
nonSmoothValue
(cern.colt.matrix.DoubleMatrix1D parIn) Computes the non-smooth value based on the input vector.cern.colt.matrix.DoubleMatrix1D
proximalOperator
(double t, cern.colt.matrix.DoubleMatrix1D X) search()
Simple search command for GraphSearch implementation.void
setParams
(Mgm.MGMParams newParams) Setter for the fieldparams
.double
smooth
(cern.colt.matrix.DoubleMatrix1D parIn, cern.colt.matrix.DoubleMatrix1D gradOutVec) Smooths the input vector using the given gradient and returns a double value.cern.colt.matrix.DoubleMatrix1D
smoothGradient
(cern.colt.matrix.DoubleMatrix1D parIn) double
smoothValue
(cern.colt.matrix.DoubleMatrix1D parIn) Calculate the smooth value based on the input vector.static cern.colt.matrix.DoubleMatrix2D
upperTri
(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
- aDoubleMatrix2D
objecty
- aDoubleMatrix2D
objectvariables
- aList
objectl
- an array ofinvalid reference
int
lambda
- an array ofinvalid reference
double
-
Mgm
Constructor for Mgm.
- Parameters:
ds
- aDataSet
objectlambda
- an array ofinvalid reference
double
-
-
Method Details
-
flatten
public static cern.colt.matrix.DoubleMatrix1D flatten(cern.colt.matrix.DoubleMatrix2D m) flatten.
- Parameters:
m
- aDoubleMatrix2D
object- Returns:
- a
DoubleMatrix1D
object
-
upperTri
public static cern.colt.matrix.DoubleMatrix2D upperTri(cern.colt.matrix.DoubleMatrix2D mat, int di) upperTri.
- Parameters:
mat
- aDoubleMatrix2D
objectdi
- a int- Returns:
- a
DoubleMatrix2D
object
-
main
main.
- Parameters:
args
- an array ofString
objects
-
setParams
Setter for the field
params
.- Parameters:
newParams
- aMgm.MGMParams
object
-
smoothValue
public double smoothValue(cern.colt.matrix.DoubleMatrix1D parIn) Calculate the smooth value based on the input vector.- Parameters:
parIn
- input vector- Returns:
- the smooth value
-
smooth
public double smooth(cern.colt.matrix.DoubleMatrix1D parIn, cern.colt.matrix.DoubleMatrix1D gradOutVec) Smooths the input vector using the given gradient and returns a double value.- Overrides:
smooth
in classConvexProximal
- Parameters:
parIn
- the input vectorgradOutVec
- the gradient of g(X)- Returns:
- the smoothed value
-
nonSmoothValue
public double nonSmoothValue(cern.colt.matrix.DoubleMatrix1D parIn) Computes the non-smooth value based on the input vector.- Parameters:
parIn
- the input vector- Returns:
- the non-smooth value
-
smoothGradient
public cern.colt.matrix.DoubleMatrix1D smoothGradient(cern.colt.matrix.DoubleMatrix1D parIn) Gradient of the pseudolikelihood
-
proximalOperator
public cern.colt.matrix.DoubleMatrix1D proximalOperator(double t, cern.colt.matrix.DoubleMatrix1D X) A proximal operator for the MGM
-
nonSmooth
public double nonSmooth(double t, cern.colt.matrix.DoubleMatrix1D X, cern.colt.matrix.DoubleMatrix1D pX) Calculate value of h(X) and proxOperator of h(X) at the same time for efficiency reasons.Calculates penalty term and proximal operator at the same time for speed
- Overrides:
nonSmooth
in classConvexProximal
- Parameters:
t
- positive parameter for prox operatorX
- input vectorpX
- vector solution to prox_t(X)- Returns:
- value of h(X)
-
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
Graph
object
-
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
DoubleMatrix2D
object
-
search
Simple search command for GraphSearch implementation. Uses default edge convergence, 1000 iter limit.- Specified by:
search
in interfaceIGraphSearch
- Returns:
- a
Graph
object
-
getElapsedTime
public long getElapsedTime()Return time of execution for learning.- Returns:
- a long
-