econml.grf.CausalForest
- class econml.grf.CausalForest(n_estimators=100, *, criterion='mse', max_depth=None, min_samples_split=10, min_samples_leaf=5, min_weight_fraction_leaf=0.0, min_var_fraction_leaf=None, min_var_leaf_on_val=False, max_features='auto', min_impurity_decrease=0.0, max_samples=0.45, min_balancedness_tol=0.45, honest=True, inference=True, fit_intercept=True, subforest_size=4, n_jobs=- 1, random_state=None, verbose=0, warm_start=False)[source]
Bases:
econml.grf._base_grf.BaseGRF
A Causal Forest [cf1]. It fits a forest that solves the local moment equation problem:
E[ (Y - <theta(x), T> - beta(x)) (T;1) | X=x] = 0
Each node in the tree contains a local estimate of the parameter theta(x), for every region of X that falls within that leaf.
- Parameters
n_estimators (int, default=100) – Number of trees
criterion ({
"mse"
,"het"
}, default=”mse”) – The function to measure the quality of a split. Supported criteria are “mse” for the mean squared error in a linear moment estimation tree and “het” for heterogeneity score.The “mse” criterion finds splits that minimize the score:
sum_{child} E[(Y - <theta(child), T> - beta(child))^2 | X=child] weight(child)
Internally, for the case of more than two treatments or for the case of two treatments with
fit_intercept=True
then this criterion is approximated by computationally simpler variants for computational purposes. In particular, it is replaced by:sum_{child} weight(child) * rho(child).T @ E[(T;1) @ (T;1).T | X in child] @ rho(child)
where:
rho(child) := E[(T;1) @ (T;1).T | X in parent]^{-1} * E[(Y - <theta(x), T> - beta(x)) (T;1) | X in child]
This can be thought as a heterogeneity inducing score, but putting more weight on scores with a large minimum eigenvalue of the child jacobian
E[(T;1) @ (T;1).T | X in child]
, which leads to smaller variance of the estimate and stronger identification of the parameters.The “het” criterion finds splits that maximize the pure parameter heterogeneity score:
sum_{child} weight(child) * rho(child)[:n_T].T @ rho(child)[:n_T]
This can be thought as an approximation to the ideal heterogeneity score:
weight(left) * weight(right) || theta(left) - theta(right)||_2^2 / weight(parent)^2
as outlined in [cf1]
max_depth (int, default=None) – The maximum depth of the tree. If None, then nodes are expanded until all leaves are pure or until all leaves contain less than min_samples_split samples.
min_samples_split (int or float, default=10) – The minimum number of samples required to split an internal node:
If int, then consider min_samples_split as the minimum number.
If float, then min_samples_split is a fraction and ceil(min_samples_split * n_samples) are the minimum number of samples for each split.
min_samples_leaf (int or float, default=5) – The minimum number of samples required to be at a leaf node. A split point at any depth will only be considered if it leaves at least
min_samples_leaf
training samples in each of the left and right branches. This may have the effect of smoothing the model, especially in regression.If int, then consider min_samples_leaf as the minimum number.
If float, then min_samples_leaf is a fraction and ceil(min_samples_leaf * n_samples) are the minimum number of samples for each node.
min_weight_fraction_leaf (float, default=0.0) – The minimum weighted fraction of the sum total of weights (of all the input samples) required to be at a leaf node. Samples have equal weight when sample_weight is not provided.
min_var_fraction_leaf (None or float in (0, 1], default=None) – A constraint on some proxy of the variation of the treatment vector that should be contained within each leaf as a percentage of the total variance of the treatment vector on the whole sample. This avoids performing splits where either the variance of the treatment is small and hence the local parameter is not well identified and has high variance. The proxy of variance is different for different criterion, primarily for computational efficiency reasons.
If
criterion='het'
, then this constraint translates to:for all i in {1, ..., T.shape[1]}: E[T[i]^2 | X in leaf] > `min_var_fraction_leaf` * E[T[i]^2]
When
T
is the residual treatment (i.e. centered), this translates to a requirement thatfor all i in {1, ..., T.shape[1]}: Var(T[i] | X in leaf) > `min_var_fraction_leaf` * Var(T[i])
If
criterion='mse'
, because the criterion stores more information about the leaf for every candidate split, then this constraint imposes further constraints on the pairwise correlations of different coordinates of each treatment, i.e.:for all i neq j: sqrt(Var(T[i]|X in leaf) * Var(T[j]|X in leaf) * (1 - rho(T[i], T[j]| in leaf)^2)) > `min_var_fraction_leaf` sqrt(Var(T[i]) * Var(T[j]) * (1 - rho(T[i], T[j])^2))
where rho(X, Y) is the Pearson correlation coefficient of two random variables X, Y. Thus this constraint also enforces that no two pairs of treatments be very co-linear within a leaf. This extra constraint primarily has bite in the case of more than two input treatments and also avoids leafs where the parameter estimate has large variance due to local co-linearities of the treatments.
min_var_leaf_on_val (bool, default=False) – Whether the min_var_fraction_leaf constraint should also be enforced to hold on the validation set of the honest split too. If min_var_leaf=None then this flag does nothing. Setting this to True should be done with caution, as this partially violates the honesty structure, since the treatment variable of the validation set is used to inform the split structure of the tree. However, this is a benign dependence as it only uses local correlation structure of the treatment T to decide whether a split is feasible.
max_features (int, float or {“auto”, “sqrt”, “log2”}, default=None) – The number of features to consider when looking for the best split:
If int, then consider max_features features at each split.
If float, then max_features is a fraction and int(max_features * n_features) features are considered at each split.
If “auto”, then max_features=n_features.
If “sqrt”, then max_features=sqrt(n_features).
If “log2”, then max_features=log2(n_features).
If None, then max_features=n_features.
Note: the search for a split does not stop until at least one valid partition of the node samples is found, even if it requires to effectively inspect more than
max_features
features.min_impurity_decrease (float, default=0.0) – A node will be split if this split induces a decrease of the impurity greater than or equal to this value. The weighted impurity decrease equation is the following:
N_t / N * (impurity - N_t_R / N_t * right_impurity - N_t_L / N_t * left_impurity)
where
N
is the total number of samples,N_t
is the number of samples at the current node,N_t_L
is the number of samples in the left child, andN_t_R
is the number of samples in the right child.N
,N_t
,N_t_R
andN_t_L
all refer to the weighted sum, ifsample_weight
is passed.max_samples (int or float in (0, 1], default=.45,) – The number of samples to use for each subsample that is used to train each tree:
If int, then train each tree on max_samples samples, sampled without replacement from all the samples
If float, then train each tree on ceil(max_samples * n_samples), sampled without replacement from all the samples.
If
inference=True
, then max_samples must either be an integer smaller than n_samples//2 or a float less than or equal to .5.min_balancedness_tol (float in [0, .5], default=.45) – How imbalanced a split we can tolerate. This enforces that each split leaves at least (.5 - min_balancedness_tol) fraction of samples on each side of the split; or fraction of the total weight of samples, when sample_weight is not None. Default value, ensures that at least 5% of the parent node weight falls in each side of the split. Set it to 0.0 for no balancedness and to .5 for perfectly balanced splits. For the formal inference theory to be valid, this has to be any positive constant bounded away from zero.
honest (bool, default=True) – Whether each tree should be trained in an honest manner, i.e. the training set is split into two equal sized subsets, the train and the val set. All samples in train are used to create the split structure and all samples in val are used to calculate the value of each node in the tree.
inference (bool, default=True) – Whether inference (i.e. confidence interval construction and uncertainty quantification of the estimates) should be enabled. If inference=True, then the estimator uses a bootstrap-of-little-bags approach to calculate the covariance of the parameter vector, with am objective Bayesian debiasing correction to ensure that variance quantities are positive.
fit_intercept (bool, default=True) – Whether we should fit an intercept nuisance parameter beta(x). If fit_intercept=False, then no (;1) is appended to the treatment variable in all calculations in this docstring. If fit_intercept=True, then the constant treatment of (;1) is appended to each treatment vector and the coefficient in front of this constant treatment is the intercept beta(x). beta(x) is treated as a nuisance and not returned by the predict(X), predict_and_var(X) or the predict_var(X) methods. Use predict_full(X) to recover the intercept term too.
subforest_size (int, default=4,) – The number of trees in each sub-forest that is used in the bootstrap-of-little-bags calculation. The parameter n_estimators must be divisible by subforest_size. Should typically be a small constant.
n_jobs (int or None, default=-1) – The number of parallel jobs to be used for parallelism; follows joblib semantics.
n_jobs=-1
means all available cpu cores.n_jobs=None
means no parallelism.random_state (int, RandomState instance or None, default=None) – Controls the randomness of the estimator. The features are always randomly permuted at each split. When
max_features < n_features
, the algorithm will selectmax_features
at random at each split before finding the best split among them. But the best found split may vary across different runs, even ifmax_features=n_features
. That is the case, if the improvement of the criterion is identical for several splits and one split has to be selected at random. To obtain a deterministic behaviour during fitting,random_state
has to be fixed to an integer.verbose (int, default=0) – Controls the verbosity when fitting and predicting.
warm_start (bool, default=``False``) – When set to
True
, reuse the solution of the previous call to fit and add more estimators to the ensemble, otherwise, just fit a whole new forest. IfTrue
, then oob_predict method for out-of-bag predictions is not available.
- feature_importances_
The feature importances based on the amount of parameter heterogeneity they create. The higher, the more important the feature. The importance of a feature is computed as the (normalized) total heterogeneity that the feature creates. Each split that the feature was chosen adds:
parent_weight * (left_weight * right_weight) * mean((value_left[k] - value_right[k])**2) / parent_weight**2
to the importance of the feature. Each such quantity is also weighted by the depth of the split. By default splits below
max_depth=4
are not used in this calculation and also each split at depth depth, is re-weighted by1 / (1 + `depth`)**2.0
. See the methodfeature_importances
for a method that allows one to change these defaults.- Type
ndarray of shape (n_features,)
- estimators_
The fitted trees.
- Type
list of objects of type
GRFTree
References
- cf1(1,2)
Athey, Susan, Julie Tibshirani, and Stefan Wager. “Generalized random forests.” The Annals of Statistics 47.2 (2019): 1148-1178 https://arxiv.org/pdf/1610.01271.pdf
- __init__(n_estimators=100, *, criterion='mse', max_depth=None, min_samples_split=10, min_samples_leaf=5, min_weight_fraction_leaf=0.0, min_var_fraction_leaf=None, min_var_leaf_on_val=False, max_features='auto', min_impurity_decrease=0.0, max_samples=0.45, min_balancedness_tol=0.45, honest=True, inference=True, fit_intercept=True, subforest_size=4, n_jobs=- 1, random_state=None, verbose=0, warm_start=False)[source]
Methods
__init__
([n_estimators, criterion, ...])apply
(X)Apply trees in the forest to X, return leaf indices.
Return the decision path in the forest.
feature_importances
([max_depth, ...])The feature importances based on the amount of parameter heterogeneity they create. The higher, the more important the feature. The importance of a feature is computed as the (normalized) total heterogeneity that the feature creates. For each tree and for each split that the feature was chosen adds::.
fit
(X, T, y, *[, sample_weight])Build a causal forest of trees from the training set (X, T, y).
get_params
([deep])Get parameters for this estimator.
Re-generate the example same sample indices as those at fit time using same pseudo-randomness.
oob_predict
(Xtrain)Returns the relevant output predictions for each of the training data points, when only trees where that data point was not used are incorporated.
predict
(X[, interval, alpha])Return the prefix of relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs].
predict_alpha_and_jac
(X[, slice, parallel])Return the value of the conditional jacobian E[J | X=x] and the conditional alpha E[A | X=x] using the forest as kernel weights, i.e..
Return the prefix of relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs] and their covariance matrix.
predict_full
(X[, interval, alpha])Return the fitted local parameters for each x in X, i.e. theta(x).
predict_interval
(X[, alpha])Return the confidence interval for the relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs].
predict_moment_and_var
(X, parameter[, ...])Return the value of the conditional expected moment vector at each sample and for the given parameter estimate for each sample.
predict_projection
(X, projector)Return the inner product of the prefix of relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs], with a projector vector projector(x), i.e.::.
predict_projection_and_var
(X, projector)Return the inner product of the prefix of relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs], with a projector vector projector(x), i.e.::.
predict_projection_var
(X, projector)Return the variance of the inner product of the prefix of relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs], with a projector vector projector(x), i.e.::.
Return the prefix of relevant fitted local parameters for each X, i.e. theta(X)[1..n_relevant_outputs].
Return the fitted local parameters for each X, i.e. theta(X).
predict_var
(X)Return the covariance matrix of the prefix of relevant fitted local parameters for each x in X.
Return the standard deviation of each coordinate of the prefix of relevant fitted local parameters for each x in X.
set_params
(**params)Set the parameters of this estimator.
Attributes
- apply(X)
Apply trees in the forest to X, return leaf indices.
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.- Returns
X_leaves – For each datapoint x in X and for each tree in the forest, return the index of the leaf x ends up in.
- Return type
ndarray of shape (n_samples, n_estimators)
- decision_path(X)
Return the decision path in the forest.
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.- Returns
indicator (sparse matrix of shape (n_samples, n_nodes)) – Return a node indicator matrix where non zero elements indicates that the samples goes through the nodes. The matrix is of CSR format.
n_nodes_ptr (ndarray of shape (n_estimators + 1,)) – The columns from indicator[n_nodes_ptr[i]:n_nodes_ptr[i+1]] gives the indicator value for the i-th estimator.
- feature_importances(max_depth=4, depth_decay_exponent=2.0)
The feature importances based on the amount of parameter heterogeneity they create. The higher, the more important the feature. The importance of a feature is computed as the (normalized) total heterogeneity that the feature creates. For each tree and for each split that the feature was chosen adds:
parent_weight * (left_weight * right_weight) * mean((value_left[k] - value_right[k])**2) / parent_weight**2
to the importance of the feature. Each such quantity is also weighted by the depth of the split. These importances are normalized at the tree level and then averaged across trees.
- Parameters
max_depth (int, default=4) – Splits of depth larger than max_depth are not used in this calculation
depth_decay_exponent (double, default=2.0) – The contribution of each split to the total score is re-weighted by 1 / (1 + depth)**2.0.
- Returns
feature_importances_ – Normalized total parameter heterogeneity inducing importance of each feature
- Return type
ndarray of shape (n_features,)
- fit(X, T, y, *, sample_weight=None)[source]
Build a causal forest of trees from the training set (X, T, y).
- Parameters
X (array-like of shape (n_samples, n_features)) – The training input samples. Internally, its dtype will be converted to
dtype=np.float64
.T (array-like of shape (n_samples, n_treatments)) – The treatment vector for each sample
y (array-like of shape (n_samples,) or (n_samples, n_outcomes)) – The outcome values for each sample.
sample_weight (array-like of shape (n_samples,), default=None) – Sample weights. If None, then samples are equally weighted. Splits that would create child nodes with net zero or negative weight are ignored while searching for a split in each node.
- Returns
self
- Return type
- get_params(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 – Parameter names mapped to their values.
- Return type
- get_subsample_inds()
Re-generate the example same sample indices as those at fit time using same pseudo-randomness.
- oob_predict(Xtrain)
Returns the relevant output predictions for each of the training data points, when only trees where that data point was not used are incorporated. This method is not available is the estimator was trained with warm_start=True.
- Parameters
Xtrain ((n_training_samples, n_features) matrix) – Must be the same exact X matrix that was passed to the forest at fit time.
- Returns
oob_preds – The out-of-bag predictions of the relevant output parameters for each of the training points
- Return type
(n_training_samples, n_relevant_outputs) matrix
- predict(X, interval=False, alpha=0.05)
Return the prefix of relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs].
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.interval (bool, default=False) – Whether to return a confidence interval too
alpha (float in (0, 1), default=0.05) – The confidence level of the confidence interval. Returns a symmetric (alpha/2, 1-alpha/2) confidence interval.
- Returns
theta(X)[1, .., n_relevant_outputs] (array-like of shape (n_samples, n_relevant_outputs)) – The estimated relevant parameters for each row of X
lb(x), ub(x) (array-like of shape (n_samples, n_relevant_outputs)) – The lower and upper end of the confidence interval for each parameter. Return value is omitted if interval=False.
- predict_alpha_and_jac(X, slice=None, parallel=True)
Return the value of the conditional jacobian E[J | X=x] and the conditional alpha E[A | X=x] using the forest as kernel weights, i.e.:
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]
where w[i] is the sample weight (1.0 if sample_weight is None).
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.slice (list of int or None, default=None) – If not None, then only the trees with index in slice, will be used to calculate the mean and the variance.
parallel (bool , default=True) – Whether the averaging should happen using parallelism or not. Parallelism adds some overhead but makes it faster with many trees.
- Returns
alpha (array-like of shape (n_samples, n_outputs)) – The estimated conditional A, alpha(x) for each sample x in X
jac (array-like of shape (n_samples, n_outputs, n_outputs)) – The estimated conditional J, jac(x) for each sample x in X
- predict_and_var(X)
Return the prefix of relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs] and their covariance matrix.
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.- Returns
theta(x)[1, .., n_relevant_outputs] (array-like of shape (n_samples, n_relevant_outputs)) – The estimated relevant parameters for each row of X
var(theta(x)) (array-like of shape (n_samples, n_relevant_outputs, n_relevant_outputs)) – The covariance of theta(x)[1, .., n_relevant_outputs]
- predict_full(X, interval=False, alpha=0.05)
Return the fitted local parameters for each x in X, i.e. theta(x).
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.interval (bool, default=False) – Whether to return a confidence interval too
alpha (float in (0, 1), default=0.05) – The confidence level of the confidence interval. Returns a symmetric (alpha/2, 1-alpha/2) confidence interval.
- Returns
theta(x) (array-like of shape (n_samples, n_outputs)) – The estimated relevant parameters for each row x of X
lb(x), ub(x) (array-like of shape (n_samples, n_outputs)) – The lower and upper end of the confidence interval for each parameter. Return value is omitted if interval=False.
- predict_interval(X, alpha=0.05)
Return the confidence interval for the relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs].
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.alpha (float in (0, 1), default=0.05) – The confidence level of the confidence interval. Returns a symmetric (alpha/2, 1-alpha/2) confidence interval.
- Returns
lb(x), ub(x) – The lower and upper end of the confidence interval for each parameter. Return value is omitted if interval=False.
- Return type
array-like of shape (n_samples, n_relevant_outputs)
- predict_moment_and_var(X, parameter, slice=None, parallel=True)
Return the value of the conditional expected moment vector at each sample and for the given parameter estimate for each sample:
M(x; theta(x)) := E[J | X=x] theta(x) - E[A | X=x]
where conditional expectations are estimated based on the forest weights, i.e.:
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))
where w[i] is the sample weight (1.0 if sample_weight is None), as well as the variance of the local moment vector across trees:
Var(M_tree(x; theta(x))) = (1/n_trees) sum_{trees} M_tree(x; theta(x)) @ M_tree(x; theta(x)).T
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.parameter (array-like of shape (n_samples, n_outputs)) – An estimate of the parameter theta(x) for each sample x in X
slice (list of int or None, default=None) – If not None, then only the trees with index in slice, will be used to calculate the mean and the variance.
parallel (bool , default=True) – Whether the averaging should happen using parallelism or not. Parallelism adds some overhead but makes it faster with many trees.
- Returns
moment (array-like of shape (n_samples, n_outputs)) – The estimated conditional moment M(x; theta(x)) for each sample x in X
moment_var (array-like of shape (n_samples, n_outputs)) – The variance of the conditional moment Var(M_tree(x; theta(x))) across trees for each sample x
- predict_projection(X, projector)
Return the inner product of the prefix of relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs], with a projector vector projector(x), i.e.:
mu(x) := <theta(x)[1..n_relevant_outputs], projector(x)>
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.projector (array-like of shape (n_samples, n_relevant_outputs)) – The projector vector for each sample x in X
- Returns
mu(x) – The estimated inner product of the relevant parameters with the projector for each row x of X
- Return type
array-like of shape (n_samples, 1)
- predict_projection_and_var(X, projector)
Return the inner product of the prefix of relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs], with a projector vector projector(x), i.e.:
mu(x) := <theta(x)[1..n_relevant_outputs], projector(x)>
as well as the variance of mu(x).
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.projector (array-like of shape (n_samples, n_relevant_outputs)) – The projector vector for each sample x in X
- Returns
mu(x) (array-like of shape (n_samples, 1)) – The estimated inner product of the relevant parameters with the projector for each row x of X
var(mu(x)) (array-like of shape (n_samples, 1)) – The variance of the estimated inner product
- predict_projection_var(X, projector)
Return the variance of the inner product of the prefix of relevant fitted local parameters for each x in X, i.e. theta(x)[1..n_relevant_outputs], with a projector vector projector(x), i.e.:
Var(mu(x)) for mu(x) := <theta(x)[1..n_relevant_outputs], projector(x)>
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.projector (array-like of shape (n_samples, n_relevant_outputs)) – The projector vector for each sample x in X
- Returns
var(mu(x)) – The variance of the estimated inner product
- Return type
array-like of shape (n_samples, 1)
- predict_tree_average(X)
Return the prefix of relevant fitted local parameters for each X, i.e. theta(X)[1..n_relevant_outputs]. This method simply returns the average of the parameters estimated by each tree. predict should be preferred over pred_tree_average, as it performs a more stable averaging across trees.
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.- Returns
theta(X)[1, .., n_relevant_outputs] – The estimated relevant parameters for each row of X
- Return type
array-like of shape (n_samples, n_relevant_outputs)
- predict_tree_average_full(X)
Return the fitted local parameters for each X, i.e. theta(X). This method simply returns the average of the parameters estimated by each tree. predict_full should be preferred over pred_tree_average_full, as it performs a more stable averaging across trees.
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.- Returns
theta(X) – The estimated relevant parameters for each row of X
- Return type
array-like of shape (n_samples, n_outputs)
- predict_var(X)
Return the covariance matrix of the prefix of relevant fitted local parameters for each x in X.
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.- Returns
var(theta(x)) – The covariance of theta(x)[1, .., n_relevant_outputs]
- Return type
array-like of shape (n_samples, n_relevant_outputs, n_relevant_outputs)
- prediction_stderr(X)
Return the standard deviation of each coordinate of the prefix of relevant fitted local parameters for each x in X.
- Parameters
X (array-like of shape (n_samples, n_features)) – The input samples. Internally, it will be converted to
dtype=np.float64
.- Returns
std(theta(x)) – The standard deviation of each theta(x)[i] for i in {1, .., n_relevant_outputs}
- Return type
array-like of shape (n_samples, n_relevant_outputs)
- set_params(**params)
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline
). The latter have parameters of the form<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
**params (dict) – Estimator parameters.
- Returns
self – Estimator instance.
- Return type
estimator instance