Skip to content

Commit 589073b

Browse files
authored
Merge pull request #37 from fabian-sp/f-fda-and-mask
New features: Functional Graphical Lasso and lambda1 mask
2 parents ea83195 + 9e00f61 commit 589073b

29 files changed

+2003
-230
lines changed

.github/workflows/unit_test.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: Testing
42

5-
# Controls when the workflow will run
63
on:
7-
# Triggers the workflow on push or pull request events but only for the main branch
84
push:
9-
branches: [ main ]
5+
branches: [ master ]
106
pull_request:
117

128
# Allows you to run this workflow manually from the Actions tab
139
workflow_dispatch:
1410

15-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1611
jobs:
17-
# This workflow contains a single job called "build"
1812
build:
19-
# The type of runner that the job will run on
2013
runs-on: ubuntu-latest
2114

22-
# Steps represent a sequence of tasks that will be executed as part of the job
2315
steps:
24-
- name: GitHub Action for pytest
25-
uses: cclauss/[email protected]
16+
- uses: actions/checkout@v3
17+
18+
- uses: conda-incubator/setup-miniconda@v2
19+
with:
20+
activate-environment: gglasso_env
21+
environment-file: environment.yml
22+
python-version: 3.8
23+
24+
# Install package and run tests
25+
- name: run tests
26+
# This one is very important so we can reuse conda env from last step
27+
shell: bash -l {0}
28+
run: |
29+
pip install -e .
30+
conda list
31+
pytest gglasso/tests -v

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ formats:
2121
# Optionally set the version of Python and requirements required to build your docs
2222
python:
2323
install:
24-
- requirements: requirements.txt
24+
- requirements: readthedocs-requirements.txt
2525
- method: setuptools
2626
path: .
2727

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ Graphical Lasso problems. <br>
1414

1515
## Getting started
1616

17-
### Install via pip
17+
### Install via pip/conda
1818

19-
The package is available on pip and can be installed with
19+
The package is available on pip and conda and can be installed with
2020

2121
pip install gglasso
2222

23+
or
24+
25+
conda install -c conda-forge gglasso
26+
27+
2328
### Install from source
2429

2530
Alternatively, you can install the package from source using the following commands:
@@ -35,9 +40,9 @@ Test your installation with
3540

3641
### Advanced options
3742

38-
When installing from source, you can also install dependencies with `conda` via the command
43+
If you want to create a conda environment with full development dependencies (for building docs, testing etc), run:
3944

40-
$ while read requirement; do conda install --yes $requirement || pip install $requirement; done < requirements.txt
45+
conda env create -f environment.yml
4146

4247
If you wish to install `gglasso` in developer mode, i.e. not having to reinstall `gglasso` everytime the source code changes (either by remote or local changes), run
4348

@@ -50,18 +55,22 @@ If you wish to install `gglasso` in developer mode, i.e. not having to reinstall
5055

5156
## Algorithms
5257

53-
`GGLasso` contains algorithms for Single and Multiple Graphical Lasso problems. Moreover, it allows to model latent variables (Latent variable Graphical Lasso) in order to estimate a precision matrix of type **sparse - low rank**. The following algorithms are contained in the package.
54-
<br>
55-
1) ADMM for Single Graphical Lasso<br>
58+
`GGLasso` contains algorithms for solving a multitude of Graphical Lasso problem formulations. For all the details, we refer to the [solver overview in our documentation](https://gglasso.readthedocs.io/en/latest/solvers-overview.html).
59+
60+
The package includes solvers for the following problems:<br>
61+
62+
- **Single Graphical Lasso**<br>
63+
64+
- **Group and Fused Graphical Lasso**<br>
65+
We implemented the ADMM (see [2] and [3]) and a proximal point algorithm (see [4]).
5666

57-
2) ADMM for Group and Fused Graphical Lasso<br>
58-
The algorithm was proposed in [2] and [3]. To use this, import `ADMM_MGL` from `gglasso/solver/admm_solver`.<br>
67+
- **Non-conforming Group Graphical Lasso**<br>
68+
A Group Graphical Lasso problem where not all variables exist in all instances/datasets.
5969

60-
3) A Proximal Point method for Group and Fused Graphical Lasso<br>
61-
We implement the PPDNA Algorithm like proposed in [4]. To use this, import `warmPPDNA` from `gglasso/solver/ppdna_solver`.<br>
70+
- **Functional Graphical Lasso**<br>
71+
A variant of Graphical Lasso where each variables has a functional representation (e.g. by Fourier coefficients).
6272

63-
4) ADMM method for Group Graphical Lasso where the features/variables are non-conforming<br>
64-
Method for problems where not all variables exist in all instances/datasets. To use this, import `ext_ADMM_MGL` from `gglasso/solver/ext_admm_solver`.<br>
73+
Moreover, for all problem formulation the package allows to model latent variables (Latent variable Graphical Lasso) in order to estimate a precision matrix of type *sparse - low rank*.
6574

6675
## Citation
6776

docs/source/math-description.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,27 @@ where
114114

115115
In ``GGLasso`` we implemented an ADMM algorithm for the above described problem formulation, possibly extended with latent variables. Have a look at the :ref:`Nonconforming Group Graphical Lasso experiment` in our example gallery.
116116

117+
118+
Functional Graphical Lasso
119+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
120+
121+
Functional Graphical Lasso is a variant of Single Graphical Lasso, where each variable is not represented as a scalar, but as a function (or time series) [ref13]_. Hence, assume that each variable has a :math:`M`-dimensional representation, for example coming from Functional PCA, Fourier transform or using a spline basis.
122+
Functional Graphical Lasso can be understood as SGL but with each matrix entry being an :math:`M\times M` block, representing the association between two function variables. Therefore, the regularization results in each :math:`M\times M` block either being zero or non-zero, and typically being dense in the latter case.
123+
124+
For :math:`p` variables, we compute the covariance matrix :math:`S \in \mathbb{R}^{pM\times pM}`. The problem formulation is
125+
126+
.. math::
127+
\min_{\Theta \in \mathbb{S}^{p\cdot M}_{++}} - \log \det \Theta + \mathrm{Tr}(S\Theta) + \lambda_1 \sum_{j\neq l} \|\Theta_{jl}^M\|_{F}.
128+
129+
With latent variables, our implementation solves
130+
131+
.. math::
132+
\min_{\Theta, L \in \mathbb{S}^{p\cdot M}_{++}} - \log \det (\Theta -L) + \mathrm{Tr}(S (\Theta -L)) + \lambda_1 \sum_{j\neq l} \|\Theta_{jl}^M\|_{F} + \mu_1 \|L\|_{\star}.
133+
134+
135+
We have a simple tutorial on this in the :ref:`Functional Graphical Lasso experiment`.
136+
137+
117138
Optimization algorithms
118139
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
119140

@@ -134,6 +155,7 @@ References
134155
.. [ref10] Foygel, R. and Drton, M. (2010). Extended Bayesian Information Criteria for Gaussian Graphical Models. In Lafferty, J., Williams, C., Shawe-Taylor, J.,Zemel, R., and Culotta, A., editors, Advances in Neural Information Processing Systems, volume 23. Curran Associates, Inc.
135156
.. [ref11] Condat, L. (2013). A Direct Algorithm for 1-D Total Variation Denoising, IEEE Signal Processing Letters, vol. 20, no. 11, pp. 1054-1057.
136157
.. [ref12] Kurtz, Z. D., Bonneau, R., and Mueller, C. L. (2019). Disentangling microbial associations from hidden environmental and technical factors via latent graphical models.
158+
.. [ref13] Qiao, X., Guo, S., and James, G. M. (2019) Functional graphical models, J. Amer. Statist. Assoc., 114, 211-222.
137159
138160
139161

docs/source/solvers-doc.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ GGL nonconforming
2222
.. autofunction:: gglasso.solver.ext_admm_solver.ext_ADMM_MGL
2323

2424

25+
Functional SGL
26+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27+
28+
.. autofunction:: gglasso.solver.functional_sgl_admm.ADMM_FSGL

docs/source/solvers-overview.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Here, ``list_of_samples`` stands for your list of data samples as described abov
5252

5353
We recommend to have a look at the :ref:`Nonconforming Group Graphical Lasso experiment` in our example gallery.
5454

55+
Functional Graphical Lasso
56+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57+
58+
For Functional Graphical Lasso, we have implemented the ADMM algorithm, see ``from gglasso.solver.functional_sgl_admm import ADMM_FSGL``. Note that in [ref13]_ a block coordinate descent algorithm is proposed for solving.
5559

5660
Further Remarks - proximal operators
5761
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

environment.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: gglasso_env
2+
3+
dependencies:
4+
- python>=3.8
5+
- numpy>=1.19.2
6+
- numba>=0.53.1
7+
- scipy>=0.11.0
8+
- scikit-learn>=0.24.1
9+
- pandas
10+
- matplotlib
11+
- seaborn
12+
- networkx
13+
- decorator==4.4.2
14+
- sphinx==3.5.4
15+
- pytest
16+
- pip
17+
- pip:
18+
- regain
19+
- scikit-fda
20+
- sphinx-gallery==0.8.2
21+
- sphinx_rtd_theme==0.5.2
22+
- fdasrsf==2.3.11
23+

0 commit comments

Comments
 (0)