1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-17 01:14:35 +08:00

Adjusting gbdt.py's parameter (#660)

* Update gbdt.py

* Update gbdt.py

* Update gbdt.py
This commit is contained in:
you-n-g
2021-10-28 19:43:05 +08:00
committed by GitHub
parent 7c31012b50
commit e41c0ac90a

View File

@@ -14,11 +14,12 @@ from ...model.interpret.base import LightGBMFInt
class LGBModel(ModelFT, LightGBMFInt): class LGBModel(ModelFT, LightGBMFInt):
"""LightGBM Model""" """LightGBM Model"""
def __init__(self, loss="mse", **kwargs): def __init__(self, loss="mse", early_stopping_rounds=50, **kwargs):
if loss not in {"mse", "binary"}: if loss not in {"mse", "binary"}:
raise NotImplementedError raise NotImplementedError
self.params = {"objective": loss, "verbosity": -1} self.params = {"objective": loss, "verbosity": -1}
self.params.update(kwargs) self.params.update(kwargs)
self.early_stopping_rounds = early_stopping_rounds
self.model = None self.model = None
def _prepare_data(self, dataset: DatasetH): def _prepare_data(self, dataset: DatasetH):
@@ -44,7 +45,7 @@ class LGBModel(ModelFT, LightGBMFInt):
self, self,
dataset: DatasetH, dataset: DatasetH,
num_boost_round=1000, num_boost_round=1000,
early_stopping_rounds=50, early_stopping_rounds=None,
verbose_eval=20, verbose_eval=20,
evals_result=dict(), evals_result=dict(),
**kwargs **kwargs
@@ -56,7 +57,9 @@ class LGBModel(ModelFT, LightGBMFInt):
num_boost_round=num_boost_round, num_boost_round=num_boost_round,
valid_sets=[dtrain, dvalid], valid_sets=[dtrain, dvalid],
valid_names=["train", "valid"], valid_names=["train", "valid"],
early_stopping_rounds=early_stopping_rounds, early_stopping_rounds=(
self.early_stopping_rounds if early_stopping_rounds is None else early_stopping_rounds
),
verbose_eval=verbose_eval, verbose_eval=verbose_eval,
evals_result=evals_result, evals_result=evals_result,
**kwargs **kwargs