-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
62 lines (49 loc) · 1.49 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import warnings
import toml
from src.relativepath import PROJECT_DIR
from src.solvers.lgbm import LGBMSolver, LGBMParams
def load_settings() -> dict:
with open(PROJECT_DIR / "environment-settings.toml", encoding="utf-8") as file:
settings = toml.load(file)
enabled = settings["paths"]["enabled"]
found = False
for key, value in settings["paths"].items():
if key == enabled:
settings["paths"] = value
found = True
break
assert found, "invalid path settings"
return settings
CONFIG = load_settings()
def main() -> None:
with warnings.catch_warnings(): # warnings in preprocessing stage are ignored.
warnings.simplefilter("ignore")
solver = LGBMSolver(
CONFIG["paths"]["train"],
CONFIG["paths"]["test"],
target_column="winner",
)
params = {
"n_estimators": 2083,
"learning_rate": 0.02516607127550297,
"max_depth": 11,
"num_leaves": 31,
"n_jobs": -1,
"min_child_samples": 42,
"subsample": 0.8085392166316496,
"colsample_bytree": 0.6281848449949525,
"lambda_l1": 4.02155452669029,
"lambda_l2": 0.14096175149815865,
"min_gain_to_split": 0.2960660809801552,
"early_stop": 40,
"random_state": 42,
}
solver.solve(
LGBMParams(
**params,
n_splits=5,
)
)
# Guideline recommended Main Guard
if __name__ == "__main__":
main()