lightgbm_regressor#

LightGBM 回归器。

模块内容#

类摘要#

LightGBMRegressor

LightGBM 回归器。

内容#

class evalml.pipelines.components.estimators.regressors.lightgbm_regressor.LightGBMRegressor(boosting_type='gbdt', learning_rate=0.1, n_estimators=20, max_depth=0, num_leaves=31, min_child_samples=20, bagging_fraction=0.9, bagging_freq=0, n_jobs=-1, random_seed=0, **kwargs)[source]#

LightGBM 回归器。

参数
  • boosting_type (string) – 要使用的提升类型。默认为“gbdt”。- 'gbdt' 使用传统的梯度提升决策树 - “dart”,使用 Dropouts meet Multiple Additive Regression Trees - “goss”,使用基于梯度的单侧采样 - “rf”,使用随机森林

  • learning_rate (float) – 提升学习率。默认为 0.1。

  • n_estimators (int) – 要拟合的提升树数量。默认为 100。

  • max_depth (int) – 基学习器的最大树深度,<=0 表示无限制。默认为 0。

  • num_leaves (int) – 基学习器的最大树叶数。默认为 31。

  • min_child_samples (int) – 子节点(叶子)所需的最小数据样本数。默认为 20。

  • bagging_fraction (float) – 如果小于 1.0,LightGBM 会在每次迭代(树)中随机选择特征的子集,而不进行重采样。例如,如果设置为 0.8,LightGBM 会在训练每棵树之前选择 80% 的特征。这可用于加快训练速度并处理过拟合。默认为 0.9。

  • bagging_freq (int) – 套袋的频率。0 表示禁用套袋。k 表示每 k 次迭代执行一次套袋。每 k 次迭代,LightGBM 将随机选择 bagging_fraction * 100% 的数据用于接下来的 k 次迭代。默认为 0。

  • n_jobs (intNone) – 并行运行的线程数。-1 表示使用所有线程。默认为 -1。

  • random_seed (int) – 随机数生成器的种子。默认为 0。

属性

hyperparameter_ranges

{ “learning_rate”: Real(0.000001, 1), “boosting_type”: [“gbdt”, “dart”, “goss”, “rf”], “n_estimators”: Integer(10, 100), “max_depth”: Integer(0, 10), “num_leaves”: Integer(2, 100), “min_child_samples”: Integer(1, 100), “bagging_fraction”: Real(0.000001, 1), “bagging_freq”: Integer(0, 1),}

model_family

ModelFamily.LIGHTGBM

modifies_features

True

modifies_target

False

name

LightGBM 回归器

SEED_MAX

SEED_BOUNDS.max_bound

SEED_MIN

0

supported_problem_types

[ ProblemTypes.REGRESSION, ProblemTypes.TIME_SERIES_REGRESSION,]

training_only

False

方法

clone

构造一个具有相同参数和随机状态的新组件。

default_parameters

返回此组件的默认参数。

describe

描述组件及其参数。

feature_importance

返回与每个特征相关的重要性。

fit

将 LightGBM 回归器拟合到数据。

get_prediction_intervals

使用已拟合的回归器查找预测区间。

load

从文件路径加载组件。

needs_fitting

返回布尔值,确定组件在调用 predict、predict_proba、transform 或 feature_importances 之前是否需要拟合。

parameters

返回用于初始化组件的参数。

predict

使用已拟合的 LightGBM 回归器进行预测。

predict_proba

对标签进行概率估计。

save

将组件保存到文件路径。

update_parameters

更新组件的参数字典。

clone(self)#

构造一个具有相同参数和随机状态的新组件。

返回

此组件的新实例,具有相同的参数和随机状态。

default_parameters(cls)#

返回此组件的默认参数。

我们的约定是 Component.default_parameters == Component().parameters。

返回

此组件的默认参数。

返回类型

dict

describe(self, print_name=False, return_dict=False)#

描述组件及其参数。

参数
  • print_name (bool, optional) – 是否打印组件名称

  • return_dict (bool, optional) – 是否以 {"name": name, "parameters": parameters} 格式将描述作为字典返回

返回

如果 return_dict 为 True,则返回字典,否则返回 None。

返回类型

None 或 dict

property feature_importance(self) pandas.Series#

返回与每个特征相关的重要性。

返回

与每个特征相关的重要性。

返回类型

np.ndarray

引发

MethodPropertyNotFoundError – 如果估计器没有 feature_importance 方法或实现 feature_importance 的 component_obj。

fit(self, X, y=None)[source]#

将 LightGBM 回归器拟合到数据。

参数
  • X (pd.DataFrame) – 输入训练数据,形状为 [n_samples, n_features]。

  • y (pd.Series) – 目标训练数据,长度为 [n_samples]。

返回

self

get_prediction_intervals(self, X: pandas.DataFrame, y: Optional[pandas.Series] = None, coverage: List[float] = None, predictions: pandas.Series = None) Dict[str, pandas.Series]#

使用已拟合的回归器查找预测区间。

此函数接受拟合估计器的预测,并使用大小为 5 的窗口计算所有预测的滚动标准差。较低和较高的预测通过将每个边界的下尾概率的百分点(分位数)函数乘以滚动标准差来确定。

参数
  • X (pd.DataFrame) – 数据,形状为 [n_samples, n_features]。

  • y (pd.Series) – 目标数据。忽略。

  • coverage (list[float]) – 一个浮点数列表,取值范围在 0 和 1 之间,用于计算预测区间的上限和下限。

  • predictions (pd.Series) – 可选的要使用的预测列表。如果为 None,将使用 X 生成预测。

返回

预测区间,键的格式为 {coverage}_lower 或 {coverage}_upper。

返回类型

dict

引发

MethodPropertyNotFoundError – 如果估计器不支持时间序列回归作为问题类型。

static load(file_path)#

从文件路径加载组件。

参数

file_path (str) – 加载文件的位置。

返回

ComponentBase 对象

needs_fitting(self)#

返回布尔值,确定组件在调用 predict、predict_proba、transform 或 feature_importances 之前是否需要拟合。

对于不需要拟合或其拟合方法不执行任何操作的组件,可以将其重写为 False。

返回

True。

property parameters(self)#

返回用于初始化组件的参数。

predict(self, X)[source]#

使用已拟合的 LightGBM 回归器进行预测。

参数

X (pd.DataFrame) – 数据,形状为 [n_samples, n_features]。

返回

预测值。

返回类型

pd.Series

predict_proba(self, X: pandas.DataFrame) pandas.Series#

对标签进行概率估计。

参数

X (pd.DataFrame) – 特征。

返回

概率估计。

返回类型

pd.Series

引发

MethodPropertyNotFoundError – 如果估计器没有 predict_proba 方法或实现 predict_proba 的 component_obj。

save(self, file_path, pickle_protocol=cloudpickle.DEFAULT_PROTOCOL)#

将组件保存到文件路径。

参数
  • file_path (str) – 保存文件的位置。

  • pickle_protocol (int) – pickle 数据流格式。

update_parameters(self, update_dict, reset_fit=True)#

更新组件的参数字典。

参数
  • update_dict (dict) – 一个包含要更新参数的字典。

  • reset_fit (bool, optional) – 如果为 True,将设置 _is_fitted 为 False。