def l1_min_c(X, y, loss='squared_hinge', fit_intercept=True, intercept_scaling=1.0):
 if (loss not in ('squared_hinge', 'log')):
  raise ValueError('loss type not in ("squared_hinge", "log", "l2")')
 X = check_array(X, accept_sparse='csc')
 check_consistent_length(X, y)
 Y = LabelBinarizer(neg_label=(-1)).fit_transform(y).T
 den = np.max(np.abs(safe_sparse_dot(Y, X)))
 if fit_intercept:
  bias = (intercept_scaling * np.ones((np.size(y), 1)))
  den = max(den, abs(np.dot(Y, bias)).max())
 if (den == 0.0):
  raise ValueError('Ill-posed l1_min_c calculation: l1 will always select zero coefficients for this data')
 if (loss == 'squared_hinge'):
  return (0.5 / den)
 else:
  return (2.0 / den)

def l1_min_c ( X , y , loss = 'squared_hinge' , fit_intercept = True , intercept_scaling = 1.0 ) : if ( loss not in ( 'squared_hinge' , 'log' ) ) : raise ValueError ( 'loss type not in ("squared_hinge", "log", "l2")' ) X = check_array ( X , accept_sparse = 'csc' ) check_consistent_length ( X , y ) Y = LabelBinarizer ( neg_label = ( - 1 ) ) . fit_transform ( y ) . T den = np . max ( np . abs ( safe_sparse_dot ( Y , X ) ) ) if fit_intercept : bias = ( intercept_scaling * np . ones ( ( np . size ( y ) , 1 ) ) ) den = max ( den , abs ( np . dot ( Y , bias ) ) . max ( ) ) if ( den == 0.0 ) : raise ValueError ( 'Ill-posed l1_min_c calculation: l1 will always select zero coefficients for this data' ) if ( loss == 'squared_hinge' ) : return ( 0.5 / den ) else : return ( 2.0 / den )
return the lowest bound for c such that for c in the model is guaranteed not to be empty .