Skip to content

Instantly share code, notes, and snippets.

@chrisgorgo
Created June 27, 2013 14:40
Show Gist options
  • Save chrisgorgo/5876972 to your computer and use it in GitHub Desktop.
Save chrisgorgo/5876972 to your computer and use it in GitHub Desktop.
def partial_correlation_via_inverse(X):
model = GraphLassoCV()
model.fit(X)
prec_ = model.precision_
return -cov2corr( model.precision_ ) )
def cov2corr( A ):
"""
covariance matrix to correlation matrix.
"""
d = np.sqrt(A.diagonal())
A = ((A.T/d).T)/d
return A
@satra
Copy link

satra commented Jun 27, 2013

this looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment