from lightgbm import LGBMRegressor, LGBMClassifier
from .fanova_base import FANOVATreeInterpretBase
from ..sklearn import MoSKLearnRegressor, MoSKLearnClassifier
[docs]
class MoLGBMRegressor(MoSKLearnRegressor, FANOVATreeInterpretBase):
"""
A lightweight wrapper of :class:`lightgbm.LGBMRegressor`.
Parameters
----------
name : str, default=None
Identifier for the model instance.
*args
Variable length argument list passed to the underlying LGBMRegressor model.
**kwargs
Arbitrary keyword arguments passed to the underlying LGBMRegressor model.
"""
def __init__(self, name: str = None, *args, **kwargs):
if "estimator" in kwargs:
self.estimator = kwargs.pop("estimator")
super().__init__(name=name, estimator=LGBMRegressor(*args, **kwargs))
[docs]
def get_params(self, deep=True):
"""
Get parameters for this estimator.
Parameters
----------
deep : bool, default=True
If True, will return the parameters for this estimator and
contained subobjects that are estimators.
Returns
-------
params : dict
Parameter names mapped to their values.
"""
return self.estimator.get_params(deep=deep)
[docs]
class MoLGBMClassifier(MoSKLearnClassifier, FANOVATreeInterpretBase):
"""
A lightweight wrapper of :class:`lightgbm.LGBMClassifier`.
Parameters
----------
name : str, default=None
Identifier for the model instance.
*args
Variable length argument list passed to the underlying LGBMClassifier model.
**kwargs
Arbitrary keyword arguments passed to the underlying LGBMClassifier model.
"""
def __init__(self, name: str = None, *args, **kwargs):
super().__init__(name=name, estimator=LGBMClassifier(*args, **kwargs))
[docs]
def get_params(self, deep=True):
"""
Get parameters for this estimator.
Parameters
----------
deep : bool, default=True
If True, will return the parameters for this estimator and
contained subobjects that are estimators.
Returns
-------
params : dict
Parameter names mapped to their values.
"""
return self.estimator.get_params(deep=deep)