X_noise = np.hstack([X, rng.normal(size=(N, 200))])
X_tr, X_te, y_tr, y_te = train_test_split(X_noise, y, test_size=0.5,
random_state=526)
mle = LogisticRegression(C=np.inf, max_iter=5000).fit(X_tr, y_tr)
lasso = LogisticRegression(l1_ratio=1.0, solver="liblinear", C=0.1).fit(X_tr, y_tr)
oracle = LogisticRegression(C=np.inf).fit(X_tr[:, :2], y_tr)
print(f"MLE: train {mle.score(X_tr, y_tr):.3f} test {mle.score(X_te, y_te):.3f}")
print(f"lasso: train {lasso.score(X_tr, y_tr):.3f} test {lasso.score(X_te, y_te):.3f}"
f" nonzero {(lasso.coef_ != 0).sum()} of {X_noise.shape[1]}")
print(f"oracle: test {oracle.score(X_te[:, :2], y_te):.3f} (the two true features)")