Skip to content

Commit 646267d

Browse files
authored
[dask] use more specific method names on _DaskLGBMModel (#4004)
1 parent 7f91dc6 commit 646267d

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

python-package/lightgbm/dask.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def client_(self) -> Client:
465465

466466
return _get_dask_client(client=self.client)
467467

468-
def _lgb_getstate(self) -> Dict[Any, Any]:
468+
def _lgb_dask_getstate(self) -> Dict[Any, Any]:
469469
"""Remove un-picklable attributes before serialization."""
470470
client = self.__dict__.pop("client", None)
471471
self._other_params.pop("client", None)
@@ -474,7 +474,7 @@ def _lgb_getstate(self) -> Dict[Any, Any]:
474474
self.client = client
475475
return out
476476

477-
def _fit(
477+
def _lgb_dask_fit(
478478
self,
479479
model_factory: Type[LGBMModel],
480480
X: _DaskMatrixLike,
@@ -501,20 +501,20 @@ def _fit(
501501
)
502502

503503
self.set_params(**model.get_params())
504-
self._copy_extra_params(model, self)
504+
self._lgb_dask_copy_extra_params(model, self)
505505

506506
return self
507507

508-
def _to_local(self, model_factory: Type[LGBMModel]) -> LGBMModel:
508+
def _lgb_dask_to_local(self, model_factory: Type[LGBMModel]) -> LGBMModel:
509509
params = self.get_params()
510510
params.pop("client", None)
511511
model = model_factory(**params)
512-
self._copy_extra_params(self, model)
512+
self._lgb_dask_copy_extra_params(self, model)
513513
model._other_params.pop("client", None)
514514
return model
515515

516516
@staticmethod
517-
def _copy_extra_params(source: Union["_DaskLGBMModel", LGBMModel], dest: Union["_DaskLGBMModel", LGBMModel]) -> None:
517+
def _lgb_dask_copy_extra_params(source: Union["_DaskLGBMModel", LGBMModel], dest: Union["_DaskLGBMModel", LGBMModel]) -> None:
518518
params = source.get_params()
519519
attributes = source.__dict__
520520
extra_param_names = set(attributes.keys()).difference(params.keys())
@@ -590,7 +590,7 @@ def __init__(
590590
__init__.__doc__ = _base_doc[:_base_doc.find('Note\n')]
591591

592592
def __getstate__(self) -> Dict[Any, Any]:
593-
return self._lgb_getstate()
593+
return self._lgb_dask_getstate()
594594

595595
def fit(
596596
self,
@@ -600,7 +600,7 @@ def fit(
600600
**kwargs: Any
601601
) -> "DaskLGBMClassifier":
602602
"""Docstring is inherited from the lightgbm.LGBMClassifier.fit."""
603-
return self._fit(
603+
return self._lgb_dask_fit(
604604
model_factory=LGBMClassifier,
605605
X=X,
606606
y=y,
@@ -670,7 +670,7 @@ def to_local(self) -> LGBMClassifier:
670670
model : lightgbm.LGBMClassifier
671671
Local underlying model.
672672
"""
673-
return self._to_local(LGBMClassifier)
673+
return self._lgb_dask_to_local(LGBMClassifier)
674674

675675

676676
class DaskLGBMRegressor(LGBMRegressor, _DaskLGBMModel):
@@ -741,7 +741,7 @@ def __init__(
741741
__init__.__doc__ = _base_doc[:_base_doc.find('Note\n')]
742742

743743
def __getstate__(self) -> Dict[Any, Any]:
744-
return self._lgb_getstate()
744+
return self._lgb_dask_getstate()
745745

746746
def fit(
747747
self,
@@ -751,7 +751,7 @@ def fit(
751751
**kwargs: Any
752752
) -> "DaskLGBMRegressor":
753753
"""Docstring is inherited from the lightgbm.LGBMRegressor.fit."""
754-
return self._fit(
754+
return self._lgb_dask_fit(
755755
model_factory=LGBMRegressor,
756756
X=X,
757757
y=y,
@@ -802,7 +802,7 @@ def to_local(self) -> LGBMRegressor:
802802
model : lightgbm.LGBMRegressor
803803
Local underlying model.
804804
"""
805-
return self._to_local(LGBMRegressor)
805+
return self._lgb_dask_to_local(LGBMRegressor)
806806

807807

808808
class DaskLGBMRanker(LGBMRanker, _DaskLGBMModel):
@@ -873,7 +873,7 @@ def __init__(
873873
__init__.__doc__ = _base_doc[:_base_doc.find('Note\n')]
874874

875875
def __getstate__(self) -> Dict[Any, Any]:
876-
return self._lgb_getstate()
876+
return self._lgb_dask_getstate()
877877

878878
def fit(
879879
self,
@@ -888,7 +888,7 @@ def fit(
888888
if init_score is not None:
889889
raise RuntimeError('init_score is not currently supported in lightgbm.dask')
890890

891-
return self._fit(
891+
return self._lgb_dask_fit(
892892
model_factory=LGBMRanker,
893893
X=X,
894894
y=y,
@@ -939,4 +939,4 @@ def to_local(self) -> LGBMRanker:
939939
model : lightgbm.LGBMRanker
940940
Local underlying model.
941941
"""
942-
return self._to_local(LGBMRanker)
942+
return self._lgb_dask_to_local(LGBMRanker)

0 commit comments

Comments
 (0)