10000 DOC add display in See Also for plotting functions and additional doc… · NicolasHug/scikit-learn@9b1f746 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b1f746

Browse files
DOC add display in See Also for plotting functions and additional docstring fixes (scikit-learn#18314)
1 parent 49d26cb commit 9b1f746

13 files changed

+259
-232
lines changed

sklearn/inspection/_partial_dependence.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _grid_from_X(X, percentiles, grid_resolution):
4848
Parameters
4949
----------
5050
X : ndarray, shape (n_samples, n_target_features)
51-
The data
51+
The data.
5252
5353
percentiles : tuple of floats
5454
The percentiles which are used to construct the extreme values of
@@ -358,6 +358,11 @@ def partial_dependence(estimator, X, features, *, response_method='auto',
358358
``grid_resolution``, or the number of unique values in ``X[:, j]``,
359359
whichever is smaller. Only available when `kind="legacy"`.
360360
361+
See Also
362+
--------
363+
plot_partial_dependence : Plot Partial Dependence.
364+
PartialDependenceDisplay : Partial Dependence visualization.
365+
361366
Examples
362367
--------
363368
>>> X = [[0, 0, 2], [1, 0, 0]]
@@ -367,10 +372,6 @@ def partial_dependence(estimator, X, features, *, response_method='auto',
367372
>>> partial_dependence(gb, features=[0], X=X, percentiles=(0, 1),
368373
... grid_resolution=2) # doctest: +SKIP
369374
(array([[-4.52..., 4.52...]]), [array([ 0., 1.])])
370-
371-
See also
372-
--------
373-
sklearn.inspection.plot_partial_dependence: Plot partial dependence
374375
"""
375376
if not (is_classifier(estimator) or is_regressor(estimator)):
376377
raise ValueError(

sklearn/inspection/_permutation_importance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Permutation importance for estimators"""
1+
"""Permutation importance for estimators."""
22
import numpy as np
33
from joblib import Parallel
44
from joblib import delayed

sklearn/inspection/_plot/partial_dependence.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,12 @@ def plot_partial_dependence(estimator, X, features, *, feature_names=None,
211211
212212
Returns
213213
-------
214-
display: :class:`~sklearn.inspection.PartialDependenceDisplay`
214+
display : :class:`~sklearn.inspection.PartialDependenceDisplay`
215+
216+
See Also
217+
--------
218+
partial_dependence : Compute Partial Dependence values.
219+
PartialDependenceDisplay : Partial Dependence visualization.
215220
216221
Examples
217222
--------
@@ -220,11 +225,6 @@ def plot_partial_dependence(estimator, X, features, *, feature_names=None,
220225
>>> X, y = make_friedman1()
221226
>>> clf = GradientBoostingRegressor(n_estimators=10).fit(X, y)
222227
>>> plot_partial_dependence(clf, X, [0, (0, 1)]) #doctest: +SKIP
223-
224-
See also
225-
--------
226-
sklearn.inspection.partial_dependence: Return raw partial
227-
dependence values
228228
"""
229229
check_matplotlib_support('plot_partial_dependence') # noqa
230230
import matplotlib.pyplot as plt # noqa
@@ -380,7 +380,7 @@ def convert_feature(fx):
380380

381381

382382
class PartialDependenceDisplay:
383-
"""Partial Dependence Plot (PDP)
383+
"""Partial Dependence Plot (PDP).
384384
385385
This can also display individual partial dependencies which are often
386386
referred to as: Individual Condition Expectation (ICE).
@@ -479,13 +479,16 @@ class PartialDependenceDisplay:
479479
`ax` is a list of axes, `vlines_[i]` corresponds to the i-th item in
480480
`ax`. Elements that are None correspond to a nonexisting axes or an
481481
axes that does not include a PDP plot.
482+
482483
.. versionadded:: 0.23
484+
483485
deciles_hlines_ : ndarray of matplotlib LineCollection
484486
If `ax` is an axes or None, `vlines_[i, j]` is the line collection
485487
representing the y axis deciles of the i-th row and j-th column. If
486488
`ax` is a list of axes, `vlines_[i]` corresponds to the i-th item in
487489
`ax`. Elements that are None correspond to a nonexisting axes or an
488490
axes that does not include a 2-way plot.
491+
489492
.. versionadded:: 0.23
490493
491494
contours_ : ndarray of matplotlib Artists
@@ -498,6 +501,10 @@ class PartialDependenceDisplay:
498501
figure_ : matplotlib Figure
499502
Figure containing partial dependence plots.
500503
504+
See Also
505+
--------
506+
partial_dependence : Compute Partial Dependence values.
507+
plot_partial_dependence : Plot Partial Dependence.
501508
"""
502509
@_deprecate_positional_args
503510
def __init__(self, pd_results, *, features, feature_names, target_idx,
@@ -549,7 +556,7 @@ def plot(self, ax=None, n_cols=3, line_kw=None, contour_kw=None):
549556
550557
Returns
551558
-------
552-
display: :class:`~sklearn.inspection.PartialDependenceDisplay`
559+
display : :class:`~sklearn.inspection.PartialDependenceDisplay`
553560
"""
554561

555562
check_matplotlib_support("plot_partial_dependence")

sklearn/metrics/_base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Common code for all metrics
2+
Common code for all metrics.
33
44
"""
55
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
@@ -22,7 +22,7 @@
2222

2323
def _average_binary_score(binary_metric, y_true, y_score, average,
2424
sample_weight=None):
25-
"""Average a binary metric for multilabel classification
25+
"""Average a binary metric for multilabel classification.
2626
2727
Parameters
2828
----------
@@ -141,7 +141,7 @@ def _average_multiclass_ovo_score(binary_metric, y_true, y_score,
141141
Parameters
142142
----------
143143
binary_metric : callable
144-
The binary metric function to use that accepts the following as input
144+
The binary metric function to use that accepts the following as input:
145145
y_true_target : array, shape = [n_samples_target]
146146
Some sub-array of y_true for a pair of classes designated
147147
positive and negative in the one-vs-one scheme.
@@ -154,11 +154,11 @@ def _average_multiclass_ovo_score(binary_metric, y_true, y_score,
154154
155155
y_score : array-like of shape (n_samples, n_classes)
156156
Target scores corresponding to probability estimates of a sample
157-
belonging to a particular class
157+
belonging to a particular class.
158158
159159
average : {'macro', 'weighted'}, default='macro'
160160
Determines the type of averaging performed on the pairwise binary
161-
metric scores
161+
metric scores:
162162
``'macro'``:
163163
Calculate metrics for each label, and find their unweighted
164164
mean. This does not take label imbalance into account. Classes
@@ -170,7 +170,7 @@ def _average_multiclass_ovo_score(binary_metric, y_true, y_score,
170170
Returns
171171
-------
172172
score : float
173-
Average of the pairwise binary metric scores
173+
Average of the pairwise binary metric scores.
174174
"""
175175
check_consistent_length(y_true, y_score)
176176

0 commit comments

Comments
 (0)
0