# Contextualized Markov Networks

# Contextualized Markov Networks#

## Markov Networks, inferred as precision matrices, are undirected graphs where edges indicate dependencies between nodes.#

```
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
```

```
X = np.random.normal(0, 1, size=(1000, 10))
C = np.random.uniform(-1, 1, size=(1000, 5))
```

```
%%capture
from contextualized.easy import ContextualizedMarkovNetworks
cmn = ContextualizedMarkovNetworks(encoder_type='ngam', num_archetypes=16, n_bootstraps=3)
cmn.fit(C, X, max_epochs=5)
# Get networks
networks = cmn.predict_networks(C)
# Get precision matrices
precision_mats = cmn.predict_precisions(C)
```