@@ -86,8 +86,9 @@ class PartialDependenceDisplay:
86
86
87
87
.. note::
88
88
The fast ``method='recursion'`` option is only available for
89
- ``kind='average'``. Plotting individual dependencies requires using
90
- the slower ``method='brute'`` option.
89
+ `kind='average'` and `sample_weights=None`. Computing individual
90
+ dependencies and doing weighted averages requires using the slower
91
+ `method='brute'`.
91
92
92
93
.. versionadded:: 0.24
93
94
Add `kind` parameter with `'average'`, `'individual'`, and `'both'`
@@ -247,6 +248,7 @@ def from_estimator(
247
248
X ,
248
249
features ,
249
250
* ,
251
+ sample_weight = None ,
250
252
categorical_features = None ,
251
253
feature_names = None ,
252
254
target = None ,
@@ -337,6 +339,14 @@ def from_estimator(
337
339
with `kind='average'`). Each tuple must be of size 2.
338
340
If any entry is a string, then it must be in ``feature_names``.
339
341
342
+ sample_weight : array-like of shape (n_samples,), default=None
343
+ Sample weights are used to calculate weighted means when averaging the
344
+ model output. If `None`, then samples are equally weighted. If
345
+ `sample_weight` is not `None`, then `method` will be set to `'brute'`.
346
+ Note that `sample_weight` is ignored for `kind='individual'`.
347
+
348
+ .. versionadded:: 1.3
349
+
340
350
categorical_features : array-like of shape (n_features,) or shape \
341
351
(n_categorical_features,), dtype={bool, int, str}, default=None
342
352
Indicates the categorical features.
@@ -409,7 +419,8 @@ def from_estimator(
409
419
computationally intensive.
410
420
411
421
- `'auto'`: the `'recursion'` is used for estimators that support it,
412
- and `'brute'` is used otherwise.
422
+ and `'brute'` is used otherwise. If `sample_weight` is not `None`,
423
+ then `'brute'` is used regardless of the estimator.
413
424
414
425
Please see :ref:`this note <pdp_method_differences>` for
415
426
differences between the `'brute'` and `'recursion'` method.
@@ -464,9 +475,10 @@ def from_estimator(
464
475
- ``kind='average'`` results in the traditional PD plot;
465
476
- ``kind='individual'`` results in the ICE plot.
466
477
467
- Note that the fast ``method='recursion'`` option is only available for
468
- ``kind='average'``. Plotting individual dependencies requires using the
469
- slower ``method='brute'`` option.
478
+ Note that the fast `method='recursion'` option is only available for
479
+ `kind='average'` and `sample_weights=None`. Computing individual
480
+ dependencies and doing weighted averages requires using the slower
481
+ `method='brute'`.
470
482
471
483
centered : bool, default=False
472
484
If `True`, the ICE and PD lines will start at the origin of the
@@ -693,6 +705,7 @@ def from_estimator(
693
705
estimator ,
694
706
X ,
695
707
fxs ,
708
+ sample_weight = sample_weight ,
696
709
feature_names = feature_names ,
697
710
categorical_features = categorical_features ,
698
711
response_method = response_method ,
0 commit comments