def _cov(X, shrinkage=None):
 shrinkage = ('empirical' if (shrinkage is None) else shrinkage)
 if isinstance(shrinkage, string_types):
  if (shrinkage == 'auto'):
   sc = StandardScaler()
   X = sc.fit_transform(X)
   s = ledoit_wolf(X)[0]
   s = ((sc.scale_[:, np.newaxis] * s) * sc.scale_[np.newaxis, :])
  elif (shrinkage == 'empirical'):
   s = empirical_covariance(X)
  else:
   raise ValueError('unknown shrinkage parameter')
 elif (isinstance(shrinkage, float) or isinstance(shrinkage, int)):
  if ((shrinkage < 0) or (shrinkage > 1)):
   raise ValueError('shrinkage parameter must be between 0 and 1')
  s = shrunk_covariance(empirical_covariance(X), shrinkage)
 else:
  raise TypeError('shrinkage must be of string or int type')
 return s

def _cov ( X , shrinkage = None ) : shrinkage = ( 'empirical' if ( shrinkage is None ) else shrinkage ) if isinstance ( shrinkage , string_types ) : if ( shrinkage == 'auto' ) : sc = StandardScaler ( ) X = sc . fit_transform ( X ) s = ledoit_wolf ( X ) [ 0 ] s = ( ( sc . scale_ [ : , np . newaxis ] * s ) * sc . scale_ [ np . newaxis , : ] ) elif ( shrinkage == 'empirical' ) : s = empirical_covariance ( X ) else : raise ValueError ( 'unknown shrinkage parameter' ) elif ( isinstance ( shrinkage , float ) or isinstance ( shrinkage , int ) ) : if ( ( shrinkage < 0 ) or ( shrinkage > 1 ) ) : raise ValueError ( 'shrinkage parameter must be between 0 and 1' ) s = shrunk_covariance ( empirical_covariance ( X ) , shrinkage ) else : raise TypeError ( 'shrinkage must be of string or int type' ) return s
estimate covariance matrix .