@@ -0,0 +1,1214 @@
+import numpy as np%0Afrom sklearn.covariance import GraphLasso%0Aimport matplotlib.pyplot as plt%0Aimport networkx as nx%0Aimport os%0A%0A#These column names are from http://www-stat.stanford.edu/~tibs/ElemStatLearn/datasets/sachs.info%0AProteinNames = %5B'praf', 'pmek', 'plcg', 'PIP2', 'PIP3','p44/42', 'pakts473', 'PKA', 'PKC', 'P38', 'pjnk'%5D%0ANCols = len(ProteinNames)%0A%0A#Import the data and convert to a numpy array%0AX = open(os.path.join('data', 'sachsCtsHTF.txt'), 'r').read().split()%0AX = %5Bfloat(x) for x in X%5D%0AX = np.array(X).reshape(-1,NCols)%0AX -= X.mean(axis=0).reshape(1,-1)%0AX /= np.sqrt(1000) #same as http://www-stat.stanford.edu/~tibs/ElemStatLearn/datasets/sachs.info%0A%0A#Regularization parameters%0ALambs = %5B36, 27, 7, 0%5D %0A%0Afor lam in Lambs:%0A    GL = GraphLasso(lam)%0A    GL.fit(X)%0A    %0A    prec = GL.precision_%0A    %0A    #Form graph%0A    G = nx.Graph()%0A    G.add_nodes_from(ProteinNames)%0A    %0A    for i in range(NCols):%0A        for j in range(i):%0A            if prec%5Bi,j%5D!=0:%0A                G.add_edges_from(%5B(ProteinNames%5Bi%5D,ProteinNames%5Bj%5D)%5D)%0A    %0A    nx.draw_circular(G, edge_color ='blue', node_color ='yellow', with_labels = True, node_size = 3000)%0A    plt.savefig(os.path.join('figures', 'glassoSachs%25s.pdf' %25 lam))%0A

Create ggmLassoDemo.py