rf_regressor#

随机森林回归器。

模块内容#

类摘要#

RandomForestRegressor

随机森林回归器。

目录#

class evalml.pipelines.components.estimators.regressors.rf_regressor.RandomForestRegressor(n_estimators: int = 100, max_depth: int = 6, n_jobs: int = -1, random_seed: Union[int, float] = 0, **kwargs)[source]#

随机森林回归器。

参数
  • n_estimators (float) – 森林中的树木数量。默认为 100。

  • max_depth (int) – 基本学习器的最大树深度。默认为 6。

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

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

属性

hyperparameter_ranges

{ “n_estimators”: Integer(10, 1000), “max_depth”: Integer(1, 32),}

model_family

ModelFamily.RANDOM_FOREST

modifies_features

True

modifies_target

False

name

随机森林回归器

supported_problem_types

[ ProblemTypes.REGRESSION, ProblemTypes.TIME_SERIES_REGRESSION, ProblemTypes.MULTISERIES_TIME_SERIES_REGRESSION,]

training_only

False

方法

clone

使用相同的参数和随机状态构建一个新组件。

default_parameters

返回此组件的默认参数。

describe

描述组件及其参数。

feature_importance

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

fit

将估计器拟合到数据。

get_prediction_intervals

使用拟合好的 RandomForestRegressor 查找预测区间。

load

从文件路径加载组件。

needs_fitting

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

parameters

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

predict

使用选定的特征进行预测。

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, 可选) – 是否打印组件名称

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

返回

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

返回类型

None 或 dict

property feature_importance(self) pandas.Series#

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

返回

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

返回类型

np.ndarray

抛出

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

fit(self, X: pandas.DataFrame, y: Optional[pandas.Series] = None)#

将估计器拟合到数据。

参数
  • 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][source]#

使用拟合好的 RandomForestRegressor 查找预测区间。

参数
  • 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

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: pandas.DataFrame) pandas.Series#

使用选定的特征进行预测。

参数

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

返回

预测值。

返回类型

pd.Series

抛出

MethodPropertyNotFoundError – 如果估计器没有 predict 方法,或者 component_obj 没有实现 predict。

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

对标签进行概率估计。

参数

X (pd.DataFrame) – 特征。

返回

概率估计。

返回类型

pd.Series

抛出

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

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, 可选) – 如果为 True,将设置 _is_fitted 为 False。