SQUIC is a second-order, L1-regularized maximum likelihood method for performant large-scale sparse precision matrix estimation. This repository contains the source code for the Python interface of SQUIC.
Project description
SQUIC for Python
SQUIC is a second-order, L1-regularized maximum likelihood method for performant large-scale sparse precision matrix estimation. This repository contains the source code for the Python(v3) interface of SQUIC.
For an interactive session using SQUIC for Python, see Google Colab:
Installation
Step 1:
Download the library $\mathtt{libSQUIC}$ from here, and follow its README instructions. The default and recommended location for $\mathtt{libSQUIC}$ is the home directory, i.e., ~/
. Note that precompiled versions are available.
Step 2:
Run the following command to install the library:
pip3 install squic
Use export SQUIC_LIB_PATH=/path/to/squic/
, replacing /path/to/squic/
with the path of where $\mathtt{libSQUIC}$ can be found.
If this variable is not set, the default location of $\mathtt{libSQUIC}$ is $HOME
.
This should be done before calling Python.
Example
In this example, we will use SQUIC to estimate the precision matrix of a synthetically generated dataset with correlated random variables, where the true precision matrix is tridiagonal.
import squic
import numpy as np
# generate sample from tridiagonal precision matrix
p = 1024
n = 100
l = .4
# generate a tridiagonal matrix
np.random.seed(1)
a = -0.5 * np.ones(p-1)
b = 1.25 * np.ones(p)
iC_star = np.diag(a,-1) + np.diag(b,0) + np.diag(a,1)
# generate the data
L = np.linalg.cholesky(iC_star)
Y = np.linalg.solve(L.T,np.random.randn(p,n))
[X,W,info_times,info_objective,info_logdetX,info_trSX] = squic.run(Y,l)
For further details type help(SQUIC)
or check the User Manual.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.