Skip to content

Commit e0fee86

Browse files
author
Sergey Feldman
committed
update LR to be less bad
1 parent f9aaf96 commit e0fee86

File tree

5 files changed

+82
-58
lines changed

5 files changed

+82
-58
lines changed

01_compare_baseline_models.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from sklearn.model_selection import GridSearchCV, cross_val_score, StratifiedKFold
1313
from sklearn.preprocessing import MinMaxScaler
1414
from sklearn.pipeline import Pipeline
15-
from sklearn.svm import SVC, LinearSVC
15+
from sklearn.svm import SVC
1616
from utils import load_data
1717

1818

@@ -53,7 +53,12 @@ def define_and_evaluate_pipelines(X, y, random_state=0):
5353
pipeline2 = Pipeline(
5454
[
5555
("scaler", MinMaxScaler()),
56-
("logistic", LogisticRegression(solver="saga", max_iter=10000, random_state=random_state)),
56+
(
57+
"logistic",
58+
LogisticRegression(
59+
solver="saga", max_iter=10000, penalty="elasticnet", l1_ratio=0.1, random_state=random_state
60+
), # without elasticnet penalty, LR can get pretty bad sometimes
61+
),
5762
]
5863
)
5964
param_grid2 = {

02_lightgbm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from utils import load_data
1616

1717
N_JOBS = 4 * 4 * 9
18-
N_ITER = 25 # budget for hyperparam search
19-
18+
N_ITER = 50 # budget for hyperparam search
19+
N_STARTUP_JOBS = 20 # hyperopt does a bunch of random jobs first
2020

2121
HYPEROPT_SPACE = {
2222
"learning_rate": hp.choice("learning_rate", [0.1, 0.05, 0.01, 0.005, 0.001]),
@@ -71,7 +71,7 @@ def obj(params):
7171
_ = fmin(
7272
fn=obj,
7373
space=HYPEROPT_SPACE,
74-
algo=partial(tpe.suggest, n_startup_jobs=5),
74+
algo=partial(tpe.suggest, n_startup_jobs=N_STARTUP_JOBS),
7575
max_evals=N_ITER,
7676
trials=trials,
7777
rstate=np.random.RandomState(random_state),

figures.ipynb

Lines changed: 72 additions & 53 deletions
Large diffs are not rendered by default.
34 Bytes
Binary file not shown.
5.73 KB
Binary file not shown.

0 commit comments

Comments
 (0)