def check_l1_min_c(X, y, loss, fit_intercept=True, intercept_scaling=None): min_c = l1_min_c(X, y, loss, fit_intercept, intercept_scaling) clf = { ('log', False): LogisticRegression(penalty='l1'), ('log', True): SparseLogRegression(penalty='l1'), ('l2', False): LinearSVC(loss='l2', penalty='l1', dual=False), ('l2', True): SparseSVC(loss='l2', penalty='l1', dual=False), }[loss, sp.issparse(X)] clf.fit_intercept = fit_intercept clf.intercept_scaling = intercept_scaling clf.C = min_c clf.fit(X, y) assert (np.asanyarray(clf.coef_) == 0).all() assert (np.asanyarray(clf.intercept_) == 0).all() clf.C = min_c * 1.01 clf.fit(X, y) assert (np.asanyarray(clf.coef_) != 0).any() or \ (np.asanyarray(clf.intercept_) != 0).any()
def test_unsupported_loss(): l1_min_c(dense_X, Y1, 'l1')
def test_ill_posed_min_c(): X = [[0, 0], [0, 0]] y = [0, 1] l1_min_c(X, y)