econml.grf.RegressionForest

class econml.grf.RegressionForest(n_estimators=100, *, max_depth=None, min_samples_split=10, min_samples_leaf=5, min_weight_fraction_leaf=0.0, max_features='auto', min_impurity_decrease=0.0, max_samples=0.45, min_balancedness_tol=0.45, honest=True, inference=True, subforest_size=4, n_jobs=- 1, random_state=None, verbose=0, warm_start=False)[source]

基类: econml.grf._base_grf.BaseGRF

在 sklearn 回归树之上实现的子样本诚实随机森林回归器。它实现了 [rf3] 中描述的子采样和诚实性,但使用 scikit-learn 回归树作为基础。它提供了基于 [rf3][rf4] 中描述思想的置信区间。

随机森林是一种元估计器,它在数据集的各种子样本上拟合多个分类决策树,并使用平均方法来提高预测准确性和控制过拟合。子样本大小小于原始大小,且子采样是无放回抽样。每棵决策树都以诚实的方式构建:一半的子样本数据用于创建树结构(称为分裂样本),另一半用于计算树的每个叶子处的常数回归估计(称为估计样本)。与 [rf3] 中提出的算法的一个不同之处在于,我们不确保平衡性,也不考虑特征的泊松抽样,以确保每个特征在每次分裂时都有被选中的正概率。相反,我们使用 Breiman 的原始算法 [rf1],该算法从候选分裂的集合中选择最佳分裂,只要未达到 `max_depth`,并且叶子节点不超过 max_leafs,每个子节点包含至少 `min_samples_leaf` 个样本且总权重分数至少为 `min_weight_fraction_leaf`。此外,它允许使用均方误差 (MSE) 和平均绝对误差 (MAE) 作为分裂准则。最后,如果准则改进不超过 `min_impurity_decrease`,则允许提前停止分裂。这些技术源于 [rf1] 的工作,应该能带来有限样本性能的改进,特别是对于高维特征。

该实现还使用 [rf3] 中描述的小袋自助法为每个预测提供置信区间:子采样在层次级别执行,首先随机抽取一组半样本,然后从每个半样本中进行子采样以构建森林的森林。所有树都用于点预测,并且由每个子森林返回的预测分布用于计算点预测的标准误差。

参数
  • n_estimators (int, default 100) – 树的数量

  • max_depth (int, default None) – 树的最大深度。如果为 None,则节点会扩展,直到所有叶子纯净或直到所有叶子包含少于 min_samples_split 个样本。

  • min_samples_split (int or float, default 10) – 分裂内部节点所需的最小样本数

    • 如果为 int,则将 min_samples_split 视为最小数量。

    • 如果为 float,则 min_samples_split 是一个分数,并且 ceil(min_samples_split * n_samples) 是每次分裂所需的最小样本数。

  • min_samples_leaf (int or float, default 5) – 叶节点所需的最小样本数。仅当分裂点在任何深度下在左分支和右分支中都至少留下 min_samples_leaf 个训练样本时,才会考虑该分裂点。这可能会对模型产生平滑作用,特别是在回归中。

    • 如果为 int,则将 min_samples_leaf 视为最小数量。

    • 如果为 float,则 min_samples_leaf 是一个分数,并且 ceil(min_samples_leaf * n_samples) 是每个节点所需的最小样本数。

  • min_weight_fraction_leaf (float, default 0.0) – 叶节点所需的总权重(所有输入样本的总和)的最小加权比例。当未提供 sample_weight 时,样本具有相同的权重。

  • max_features (int, float, {“auto”, “sqrt”, “log2”}, or None, default None) – 寻找最佳分裂时要考虑的特征数量

    • 如果为 int,则在每次分裂时考虑 max_features 个特征。

    • 如果为 float,则 max_features 是一个分数,并且在每次分裂时考虑 int(max_features * n_features) 个特征。

    • 如果为 “auto”,则 max_features=n_features

    • 如果为 “sqrt”,则 max_features=sqrt(n_features)

    • 如果为 “log2”,则 max_features=log2(n_features)

    • 如果为 None,则 max_features=n_features

    注意:寻找分裂的过程不会停止,直到找到至少一个有效的节点样本分区,即使这需要实际检查超过 max_features 个特征。

  • min_impurity_decrease (float, default 0.0) – 如果分裂导致的杂质减少大于或等于此值,则会分裂节点。加权杂质减少的公式如下

    N_t / N * (impurity - N_t_R / N_t * right_impurity
                        - N_t_L / N_t * left_impurity)
    

    其中 N 是样本总数,N_t 是当前节点的样本数,N_t_L 是左子节点的样本数,N_t_R 是右子节点的样本数。如果传入了 sample_weight,则 NN_tN_t_RN_t_L 都指的是加权和。

  • max_samples (int or float in (0, 1], default .45,) – 用于训练每棵树的每个子样本的样本数

    • 如果为 int,则使用 max_samples 个样本训练每棵树,这些样本从所有样本中无放回抽样。

    • 如果为 float,则使用 ceil(max_samples * n_samples) 个样本训练每棵树,这些样本从所有样本中无放回抽样。

    如果 inference=True,则 max_samples 必须是小于 n_samples//2 的整数,或者是小于或等于 0.5 的浮点数。

  • min_balancedness_tol (float in [0, .5], default .45) – 我们能容忍的分裂不平衡程度。这强制要求每次分裂在分裂的两侧至少留下 (.5 - min_balancedness_tol) 比例的样本;或者当 sample_weight 不为 None 时,总样本权重的比例。默认值确保父节点权重的至少 5% 落入分裂的每一侧。设置为 0.0 表示不强制平衡,设置为 0.5 表示完美平衡分裂。对于正式的推断理论有效,这必须是任何有界且远离零的正常数。

  • honest (bool, default True) – 每棵树是否应该以诚实的方式训练,即训练集被分成两个大小相等的子集:训练集和验证集。训练集中的所有样本用于创建分裂结构,验证集中的所有样本用于计算树中每个节点的值。

  • inference (bool, default True) – 是否应启用推断(即置信区间构建和估计的不确定性量化)。如果 inference=True,估计器将使用小袋自助法计算参数向量的协方差,并采用客观贝叶斯去偏校正以确保方差量为正。

  • subforest_size (int, default 4,) – 用于小袋自助法计算的每个子森林中的树的数量。参数 n_estimators 必须能被 subforest_size 整除。通常应该是一个小的常数。

  • n_jobs (int or None, default -1) – 用于并行处理的并行作业数;遵循 joblib 语义。n_jobs=-1 表示所有可用的 CPU 核心。n_jobs=None 表示不使用并行。

  • random_state (int, RandomState instance, or None, default None) – 控制估计器的随机性。在每次分裂时,特征总是随机排列的。当 max_features < n_features 时,算法会在每次分裂前随机选择 max_features 个特征,然后在其中找到最佳分裂。但是找到的最佳分裂在不同的运行中可能会有所不同,即使 max_features=n_features 也是如此。当多个分裂的准则改进相同时,必须随机选择一个分裂,这就是这种情况。为了在拟合期间获得确定性行为,random_state 必须固定为一个整数。

  • verbose (int, default 0) – 控制拟合和预测时的详细程度。

  • warm_start (bool, default False) – 设置为 True 时,重用上次调用 fit 的结果并向集成中添加更多估计器,否则,只拟合一个新的整个森林。如果为 True,则无法使用 oob_predict 方法进行袋外预测。

feature_importances_

基于特征所产生的参数异质性量度的特征重要性。值越高,特征越重要。特征的重要性计算为其产生的(归一化)总异质性。该特征被选中的每次分裂都会增加

parent_weight * (left_weight * right_weight)
    * mean((value_left[k] - value_right[k])**2) / parent_weight**2

到特征的重要性中。每个这样的量也按分裂的深度加权。默认情况下,深度小于 max_depth=4 的分裂不用于此计算,并且每个深度为 depth 的分裂按 1 / (1 + `depth`)**2.0 重新加权。请参阅方法 feature_importances,该方法允许更改这些默认值。

类型

形状为 (n_features,) 的 ndarray

estimators_

拟合的树。

类型

类型为 GRFTree 的对象列表

示例

import numpy as np
from econml.grf import RegressionForest
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split

np.set_printoptions(suppress=True)
np.random.seed(123)
X, y = make_regression(n_samples=1000, n_features=4, n_informative=2,
                       random_state=0, shuffle=False)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.5)
regr = RegressionForest(max_depth=None, random_state=0,
                        n_estimators=1000)
>>> regr.fit(X_train, y_train)
RegressionForest(n_estimators=1000, random_state=0)
>>> regr.feature_importances_
array([0.88..., 0.11..., 0.00..., 0.00...])
>>> regr.predict(np.ones((1, 4)), interval=True, alpha=.05)
(array([[121.0...]]), array([[103.6...]]), array([[138.3...]]))

参考文献

rf1(1,2)
  1. Breiman, “Random Forests”, Machine Learning, 45(1), 5-32, 2001.

rf3(1,2,3,4)

S. Athey, S. Wager, “Estimation and Inference of Heterogeneous Treatment Effects using Random Forests”, Journal of the American Statistical Association 113.523 (2018): 1228-1242.

rf4

S. Athey, J. Tibshirani, and S. Wager, “Generalized random forests”, The Annals of Statistics, 47(2), 1148-1178, 2019.

__init__(n_estimators=100, *, max_depth=None, min_samples_split=10, min_samples_leaf=5, min_weight_fraction_leaf=0.0, max_features='auto', min_impurity_decrease=0.0, max_samples=0.45, min_balancedness_tol=0.45, honest=True, inference=True, subforest_size=4, n_jobs=- 1, random_state=None, verbose=0, warm_start=False)[source]

方法

__init__([n_estimators, max_depth, ...])

apply(X)

将森林中的树应用于 X,返回叶子索引。

decision_path(X)

返回森林中的决策路径。

feature_importances([max_depth, ...])

基于特征所产生的参数异质性量度的特征重要性。值越高,特征越重要。特征的重要性计算为其产生的(归一化)总异质性。对于每棵树,特征被选中的每次分裂都会增加::。

fit(X, y, *[, sample_weight])

从训练集 (X, y) 构建 IV 树森林。

get_params([deep])

获取此估计器的参数。

get_subsample_inds()

使用相同的伪随机性重新生成与拟合时相同的样本索引。

oob_predict(Xtrain)

当仅包含未使用该数据点的树时,返回每个训练数据点的相关输出预测。

predict(X[, interval, alpha])

返回 X 中每个 x 的相关拟合局部参数前缀,即 theta(x)[1..n_relevant_outputs]。

predict_alpha_and_jac(X[, slice, parallel])

使用森林作为核权重,返回条件雅可比 E[J | X=x] 的值和条件 alpha E[A | X=x] 的值,即。

predict_and_var(X)

返回 X 中每个 x 的相关拟合局部参数前缀,即 theta(x)[1..n_relevant_outputs] 及其协方差矩阵。

predict_full(X[, interval, alpha])

返回 X 中每个 x 的拟合局部参数,即 theta(x)。

predict_interval(X[, alpha])

返回 X 中每个 x 的相关拟合局部参数的置信区间,即 theta(x)[1..n_relevant_outputs]。

predict_moment_and_var(X, parameter[, ...])

返回每个样本处的条件期望矩向量的值以及每个样本的给定参数估计值。

predict_projection(X, projector)

返回 X 中每个 x 的相关拟合局部参数前缀(即 theta(x)[1..n_relevant_outputs])与投影向量 projector(x) 的内积,即::。

predict_projection_and_var(X, projector)

返回 X 中每个 x 的相关拟合局部参数前缀(即 theta(x)[1..n_relevant_outputs])与投影向量 projector(x) 的内积,即::。

以及 mu(x) 的方差。

predict_projection_var(X, projector)

返回 X 中每个 x 的相关拟合局部参数前缀(即 theta(x)[1..n_relevant_outputs])与投影向量 projector(x) 的内积的方差,即::。

predict_tree_average(X)

返回每个 X 的相关拟合局部参数前缀,即 theta(X)[1..n_relevant_outputs]。此方法仅返回每棵树估计参数的平均值。predict 方法应优于 pred_tree_average,因为它在树之间执行更稳定的平均计算。

predict_tree_average_full(X)

返回每个 X 的拟合局部参数,即 theta(X)。此方法仅返回每棵树估计参数的平均值。predict_full 方法应优于 pred_tree_average_full,因为它在树之间执行更稳定的平均计算。

predict_var(X)

返回 X 中每个 x 的相关拟合局部参数前缀的协方差矩阵。

prediction_stderr(X)

返回 X 中每个 x 的相关拟合局部参数前缀的每个坐标的标准差。

set_params(**params)

属性

feature_importances_

apply(X)

将森林中的树应用于 X,返回叶子索引。

参数

X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

返回

X_leaves – 对于 X 中的每个数据点 x 和森林中的每棵树,返回 x 最终所在的叶子索引。

返回类型

形状为 (n_samples, n_estimators) 的 ndarray

decision_path(X)

返回森林中的决策路径。

参数

X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

返回

  • indicator (形状为 (n_samples, n_nodes) 的稀疏矩阵) – 返回一个节点指示矩阵,其中非零元素表示样本通过这些节点。该矩阵为 CSR 格式。

  • n_nodes_ptr (形状为 (n_estimators + 1,) 的 ndarray) – `indicator[n_nodes_ptr[i]:n_nodes_ptr[i+1]]` 的列给出第 i 个估计器的指示值。

feature_importances(max_depth=4, depth_decay_exponent=2.0)

基于特征所产生的参数异质性量度的特征重要性。值越高,特征越重要。特征的重要性计算为其产生的(归一化)总异质性。对于每棵树,特征被选中的每次分裂都会增加

parent_weight * (left_weight * right_weight)
    * mean((value_left[k] - value_right[k])**2) / parent_weight**2

到特征的重要性中。每个这样的量也按分裂的深度加权。这些重要性在树级别进行归一化,然后跨树进行平均。

参数
  • max_depth (int, default 4) – 深度大于 max_depth 的分裂不用于此计算

  • depth_decay_exponent (double, default 2.0) – 每个分裂对总得分的贡献通过 1 / (1 + depth)**2.0 进行重新加权。

返回

feature_importances_ – 每个特征的归一化总参数异质性诱导重要性

返回类型

形状为 (n_features,) 的 ndarray

fit(X, y, *, sample_weight=None)[source]

从训练集 (X, y) 构建 IV 树森林。

参数
  • X (形状为 (n_samples, n_features) 的 array_like) – 训练输入样本。在内部,其 dtype 将被转换为 dtype=np.float64

  • y (形状为 (n_samples,) 或 (n_samples, n_outcomes) 的 array_like) – 每个样本的结果值。

  • sample_weight (形状为 (n_samples,) 的 array_like, default None) – 样本权重。如果为 None,则样本具有相同的权重。在每个节点搜索分裂时,将忽略那些会创建净权重为零或负值的子节点的分裂。

返回

self

返回类型

object

get_params(deep=True)

获取此估计器的参数。

参数

deep (bool, default=True) – 如果为 True,则返回此估计器及其包含的估计器子对象的参数。

返回

params – 参数名称映射到其值。

返回类型

dict

get_subsample_inds()

使用相同的伪随机性重新生成与拟合时相同的样本索引。

使用相同的伪随机性重新生成与拟合时相同的样本索引。

oob_predict(Xtrain)

参数

当仅包含未使用该数据点的树时,返回每个训练数据点的相关输出预测。如果估计器使用 warm_start=True 进行训练,则此方法不可用。

返回

oob_preds – 每个训练点的相关输出参数的袋外预测

返回类型

形状为 (n_training_samples, n_relevant_outputs) 的矩阵

predict(X, interval=False, alpha=0.05)

返回 X 中每个 x 的相关拟合局部参数前缀,即 theta(x)[1..n_relevant_outputs]。

参数
  • X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

  • interval (bool, default False) – 是否也返回置信区间

  • alpha (float in (0, 1), default 0.05) – 置信区间的置信水平。返回对称的 (alpha/2, 1-alpha/2) 置信区间。

返回

  • theta(X)[1, .., n_relevant_outputs] (形状为 (n_samples, n_relevant_outputs) 的 array_like) – X 的每一行的估计相关参数

  • lb(x), ub(x) (形状为 (n_samples, n_relevant_outputs) 的 array_like) – 每个参数的置信区间的下端和上端。如果 interval=False,则省略返回值。

predict_alpha_and_jac(X, slice=None, parallel=True)

使用森林作为核权重,返回条件雅可比 E[J | X=x] 的值和条件 alpha E[A | X=x] 的值,即

alpha(x) = (1/n_trees) sum_{trees} (1/ |leaf(x)|) sum_{val sample i in leaf(x)} w[i] A[i]
jac(x) = (1/n_trees) sum_{trees} (1/ |leaf(x)|) sum_{val sample i in leaf(x)} w[i] J[i]

其中 w[i] 是样本权重(如果 sample_weight 为 None,则为 1.0)。

参数
  • X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

  • slice (int 列表或 None, default None) – 如果不为 None,则仅使用 slice 中索引的树来计算均值和方差。

  • parallel (bool , default True) – 平均计算是否应该使用并行处理。并行处理会增加一些开销,但在树数量很多时会更快。

返回

  • alpha (形状为 (n_samples, n_outputs) 的 array_like) – X 中每个样本 x 的估计条件 A,即 alpha(x)

  • jac (形状为 (n_samples, n_outputs, n_outputs) 的 array_like) – X 中每个样本 x 的估计条件 J,即 jac(x)

predict_and_var(X)

返回 X 中每个 x 的相关拟合局部参数前缀,即 theta(x)[1..n_relevant_outputs] 及其协方差矩阵。

参数

X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

返回

  • theta(x)[1, .., n_relevant_outputs] (形状为 (n_samples, n_relevant_outputs) 的 array_like) – X 的每一行的估计相关参数

  • var(theta(x)) (形状为 (n_samples, n_relevant_outputs, n_relevant_outputs) 的 array_like) – theta(x)[1, .., n_relevant_outputs] 的协方差

predict_full(X, interval=False, alpha=0.05)

返回 X 中每个 x 的拟合局部参数,即 theta(x)。

参数
  • X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

  • interval (bool, default False) – 是否也返回置信区间

  • alpha (float in (0, 1), default 0.05) – 置信区间的置信水平。返回对称的 (alpha/2, 1-alpha/2) 置信区间。

返回

  • theta(x) (形状为 (n_samples, n_outputs) 的 array_like) – X 的每一行 x 的估计相关参数

  • lb(x), ub(x) (形状为 (n_samples, n_outputs) 的 array_like) – 每个参数的置信区间的下端和上端。如果 interval=False,则省略返回值。

predict_interval(X, alpha=0.05)

返回 X 中每个 x 的相关拟合局部参数的置信区间,即 theta(x)[1..n_relevant_outputs]。

参数
  • X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

  • alpha (float in (0, 1), default 0.05) – 置信区间的置信水平。返回对称的 (alpha/2, 1-alpha/2) 置信区间。

返回

lb(x), ub(x) – 每个参数的置信区间的下端和上端。如果 interval=False,则省略返回值。

返回类型

形状为 (n_samples, n_relevant_outputs) 的 array_like

predict_moment_and_var(X, parameter, slice=None, parallel=True)

返回每个样本处的条件期望矩向量的值以及每个样本的给定参数估计值

M(x; theta(x)) := E[J | X=x] theta(x) - E[A | X=x]

其中条件期望是基于森林权重估计的,即

M_tree(x; theta(x)) := (1/ |leaf(x)|) sum_{val sample i in leaf(x)} w[i] (J[i] theta(x) - A[i])
M(x; theta(x) = (1/n_trees) sum_{trees} M_tree(x; theta(x))

其中 w[i] 是样本权重(如果 sample_weight 为 None,则为 1.0),以及局部矩向量在树之间的方差

Var(M_tree(x; theta(x))) = (1/n_trees) sum_{trees} M_tree(x; theta(x)) @ M_tree(x; theta(x)).T
参数
  • X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

  • parameter (形状为 (n_samples, n_outputs) 的 array_like) – X 中每个样本 x 的参数 theta(x) 的估计值

  • slice (int 列表或 None, default None) – 如果不为 None,则仅使用 slice 中索引的树来计算均值和方差。

  • parallel (bool , default True) – 平均计算是否应该使用并行处理。并行处理会增加一些开销,但在树数量很多时会更快。

返回

  • moment (形状为 (n_samples, n_outputs) 的 array_like) – X 中每个样本 x 的估计条件矩 M(x; theta(x))

  • moment_var (形状为 (n_samples, n_outputs) 的 array_like) – X 中每个样本 x 的条件矩 Var(M_tree(x; theta(x))) 在树之间的方差

predict_projection(X, projector)

返回 X 中每个 x 的相关拟合局部参数前缀(即 theta(x)[1..n_relevant_outputs])与投影向量 projector(x) 的内积,即::。

mu(x) := <theta(x)[1..n_relevant_outputs], projector(x)>
参数
  • X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

  • projector (形状为 (n_samples, n_relevant_outputs) 的 array_like) – X 中每个样本 x 的投影向量

返回

mu(x) – X 的每一行 x 的相关参数与投影向量的估计内积

返回类型

形状为 (n_samples, 1) 的 array_like

predict_projection_and_var(X, projector)

返回 X 中每个 x 的相关拟合局部参数前缀(即 theta(x)[1..n_relevant_outputs])与投影向量 projector(x) 的内积,即::。

mu(x) := <theta(x)[1..n_relevant_outputs], projector(x)>

以及 mu(x) 的方差。

参数
  • X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

  • projector (形状为 (n_samples, n_relevant_outputs) 的 array_like) – X 中每个样本 x 的投影向量

返回

  • mu(x) (形状为 (n_samples, 1) 的 array_like) – X 的每一行 x 的相关参数与投影向量的估计内积

  • var(mu(x)) (形状为 (n_samples, 1) 的 array_like) – 估计内积的方差

predict_projection_var(X, projector)

返回 X 中每个 x 的相关拟合局部参数前缀(即 theta(x)[1..n_relevant_outputs])与投影向量 projector(x) 的内积的方差,即::。

Var(mu(x)) for mu(x) := <theta(x)[1..n_relevant_outputs], projector(x)>
参数
  • X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

  • projector (形状为 (n_samples, n_relevant_outputs) 的 array_like) – X 中每个样本 x 的投影向量

返回

var(mu(x)) – 估计内积的方差

返回类型

形状为 (n_samples, 1) 的 array_like

predict_tree_average(X)

返回每个 X 的相关拟合局部参数前缀,即 theta(X)[1..n_relevant_outputs]。此方法仅返回每棵树估计参数的平均值。predict 方法应优于 pred_tree_average,因为它在树之间执行更稳定的平均计算。

参数

X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

返回

theta(X)[1, .., n_relevant_outputs] – X 的每一行的估计相关参数

返回类型

形状为 (n_samples, n_relevant_outputs) 的 array_like

predict_tree_average_full(X)

返回每个 X 的拟合局部参数,即 theta(X)。此方法仅返回每棵树估计参数的平均值。predict_full 方法应优于 pred_tree_average_full,因为它在树之间执行更稳定的平均计算。

参数

X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

返回

theta(X) – X 的每一行的估计相关参数

返回类型

形状为 (n_samples, n_outputs) 的 array_like

predict_var(X)

predict_var(X)

参数

X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

返回

var(theta(x)) – theta(x)[1, .., n_relevant_outputs] 的协方差

返回类型

形状为 (n_samples, n_relevant_outputs, n_relevant_outputs) 的 array_like

prediction_stderr(X)

prediction_stderr(X)

参数

X (形状为 (n_samples, n_features) 的 array_like) – 输入样本。在内部,它将被转换为 dtype=np.float64

返回

std(theta(x)) – X 中每个 x 的相关拟合局部参数前缀的每个坐标的标准差。

返回类型

形状为 (n_samples, n_relevant_outputs) 的 array_like

set_params(**params)

set_params(**params)

此方法适用于简单的估计器以及嵌套对象(例如 Pipeline)。后者具有 <component>__<parameter> 形式的参数,因此可以更新嵌套对象的每个组件。

参数

**params (dict) – 估计器参数。

返回

self – 估计器实例。

返回类型

estimator instance