Skip to main content

A package for estimating dynamic graphical lasso with heavy tailed distributions

Project description

Tests Coverage Status

DyGraph

A package for dynamic graph estimation.

pip install DyGraph

from sklearn.datasets import make_sparse_spd_matrix
import DyGraph as dg
import numpy as np
from scipy.stats import multivariate_t as mvt

Generate some data.

d = 5  # number of nodes
A = make_sparse_spd_matrix(d, alpha=0.6)
X = mvt.rvs(loc = np.zeros(d),df = 4, shape = np.linalg.inv(A), size=200)


max_iter = 100
obs_per_graph = 50
alpha = 0.05
kappa = 0.1
kappa_gamma = 0.1
tol = 1e-4

Gaussian

dg_opt = dg.dygl_inner_em(X,  obs_per_graph = obs_per_graph, max_iter = max_iter, lamda = alpha,  kappa = kappa, tol = tol, lik_type='gaussian')
dg_opt.fit(temporal_penalty = 'element-wise')

access the graphs via:

dg_opt.theta

t, inner and outer. Can give degrees of freedom, or estimate

# inner
dg_opt_t_inner = dg.dygl_inner_em(X = X, obs_per_graph = obs_per_graph,  max_iter = max_iter, lamda = alpha, kappa = kappa, tol = tol, lik_type='t')
dg_opt_t_inner.fit(temporal_penalty = 'element-wise')
# outer
dg_opt_t_outer = dg.dygl_outer_em(X = X, obs_per_graph = obs_per_graph,  max_iter = max_iter, lamda = alpha,  kappa = kappa, tol = tol, lik_type='t')
dg_opt_t_outer.fit(temporal_penalty = 'element-wise', nu = [4]*4)  # Note one nu/DoF for each graph.

Group t

# outer
dg_opt_gt_outer = dg.dygl_outer_em(X = X, obs_per_graph = obs_per_graph,  max_iter = max_iter, lamda = alpha,  kappa = kappa, tol = tol, lik_type='group-t')
dg_opt_gt_outer.fit(temporal_penalty = 'element-wise', nu = [[4] * d]*4, groups = [0]*d)  # Note one nu/DoF for each graph and feature/group, all features in same group

skew group t

# outer
dg_opt_sgt_outer = dg.dygl_outer_em(X = X, obs_per_graph = obs_per_graph,  max_iter = max_iter, lamda = alpha,  kappa = kappa, kappa_gamma = kappa_gamma, tol = tol, lik_type='skew-group-t')
dg_opt_sgt_outer.fit(temporal_penalty = 'element-wise', nu = None, groups = [0]*d)  # nus estimate, all features in same group

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

DyGraph-0.0.3.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

DyGraph-0.0.3-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file DyGraph-0.0.3.tar.gz.

File metadata

  • Download URL: DyGraph-0.0.3.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for DyGraph-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0bf165b441b826ac49d9a71ee6adec46b87faa9adecbe1f89bc3e0a9db515d27
MD5 d55e28e16e49b924adfcb5a40d706f75
BLAKE2b-256 f8781fd37b16f2d94595a076940038fa06ce6f2828d56f019c88763e55f920d9

See more details on using hashes here.

File details

Details for the file DyGraph-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: DyGraph-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for DyGraph-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 812f5f64ba0bc56ec79c1dded5d3d703f546197a398ef044e1f0b4e8e59be83c
MD5 7c957d4a70dc287204e18cbc47ce3574
BLAKE2b-256 75de50d936d003a4e2618a8b4e88d8e7636aa34cc3de7dbf07682ada96a61ffb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page