8000 DOC Add See Also to plotting and metrics by albertvillanova · Pull Request #18314 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC Add See Also to plotting and metrics #18314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions sklearn/inspection/_partial_dependence.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _grid_from_X(X, percentiles, grid_resolution):
Parameters
----------
X : ndarray, shape (n_samples, n_target_features)
The data
The data.

percentiles : tuple of floats
The percentiles which are used to construct the extreme values of
Expand Down Expand Up @@ -358,6 +358,11 @@ def partial_dependence(estimator, X, features, *, response_method='auto',
``grid_resolution``, or the number of unique values in ``X[:, j]``,
whichever is smaller. Only available when `kind="legacy"`.

See Also
--------
plot_partial_dependence : Plot Partial Dependence.
PartialDependenceDisplay : Partial Dependence visualization.

< 10000 /td>
Examples
--------
>>> X = [[0, 0, 2], [1, 0, 0]]
Expand All @@ -367,10 +372,6 @@ def partial_dependence(estimator, X, features, *, response_method='auto',
>>> partial_dependence(gb, features=[0], X=X, percentiles=(0, 1),
... grid_resolution=2) # doctest: +SKIP
(array([[-4.52..., 4.52...]]), [array([ 0., 1.])])

See also
--------
sklearn.inspection.plot_partial_dependence: Plot partial dependence
"""
if not (is_classifier(estimator) or is_regressor(estimator)):
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion sklearn/inspection/_permutation_importance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Permutation importance for estimators"""
"""Permutation importance for estimators."""
import numpy as np
from joblib import Parallel
from joblib import delayed
Expand Down
23 changes: 15 additions & 8 deletions sklearn/inspection/_plot/partial_dependence.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ def plot_partial_dependence(estimator, X, features, *, feature_names=None,

Returns
-------
display: :class:`~sklearn.inspection.PartialDependenceDisplay`
display : :class:`~sklearn.inspection.PartialDependenceDisplay`

See Also
--------
partial_dependence : Compute Partial Dependence values.
PartialDependenceDisplay : Partial Dependence visualization.

Examples
--------
Expand All @@ -220,11 +225,6 @@ def plot_partial_dependence(estimator, X, features, *, feature_names=None,
>>> X, y = make_friedman1()
>>> clf = GradientBoostingRegressor(n_estimators=10).fit(X, y)
>>> plot_partial_dependence(clf, X, [0, (0, 1)]) #doctest: +SKIP

See also
--------
sklearn.inspection.partial_dependence: Return raw partial
dependence values
"""
check_matplotlib_support('plot_partial_dependence') # noqa
import matplotlib.pyplot as plt # noqa
Expand Down Expand Up @@ -380,7 +380,7 @@ def convert_feature(fx):


class PartialDependenceDisplay:
"""Partial Dependence Plot (PDP)
"""Partial Dependence Plot (PDP).

This can also display individual partial dependencies which are often
referred to as: Individual Condition Expectation (ICE).
Expand Down Expand Up @@ -479,13 +479,16 @@ class PartialDependenceDisplay:
`ax` is a list of axes, `vlines_[i]` corresponds to the i-th item in
`ax`. Elements that are None correspond to a nonexisting axes or an
axes that does not include a PDP plot.

.. versionadded:: 0.23

deciles_hlines_ : ndarray of matplotlib LineCollection
If `ax` is an axes or None, `vlines_[i, j]` is the line collection
representing the y axis deciles of the i-th row and j-th column. If
`ax` is a list of axes, `vlines_[i]` corresponds to the i-th item in
`ax`. Elements that are None correspond to a nonexisting axes or an
axes that does not include a 2-way plot.

.. versionadded:: 0.23

contours_ : ndarray of matplotlib Artists
Expand All @@ -498,6 +501,10 @@ class PartialDependenceDisplay:
figure_ : matplotlib Figure
Figure containing partial dependence plots.

See Also
--------
partial_dependence : Compute Partial Dependence values.
plot_partial_dependence : Plot Partial Dependence.
"""
@_deprecate_positional_args
def __init__(self, pd_results, *, features, feature_names, target_idx,
Expand Down Expand Up @@ -549,7 +556,7 @@ def plot(self, ax=None, n_cols=3, line_kw=None, contour_kw=None):

Returns
-------
display: :class:`~sklearn.inspection.PartialDependenceDisplay`
display : :class:`~sklearn.inspection.PartialDependenceDisplay`
"""

check_matplotlib_support("plot_partial_dependence")
Expand Down
12 changes: 6 additions & 6 deletions sklearn/metrics/_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Common code for all metrics
Common code for all metrics.

"""
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
Expand All @@ -22,7 +22,7 @@

def _average_binary_score(binary_metric, y_true, y_score, average,
sample_weight=None):
"""Average a binary metric for multilabel classification
"""Average a binary metric for multilabel classification.

Parameters
----------
Expand Down Expand Up @@ -141,7 +141,7 @@ def _average_multiclass_ovo_score(binary_metric, y_true, y_score,
Parameters
----------
binary_metric : callable
The binary metric function to use that accepts the following as input
The binary metric function to use that accepts the following as input:
y_true_target : array, shape = [n_samples_target]
Some sub-array of y_true for a pair of classes designated
positive and negative in the one-vs-one scheme.
Expand All @@ -154,11 +154,11 @@ def _average_multiclass_ovo_score(binary_metric, y_true, y_score,

y_score : array-like of shape (n_samples, n_classes)
Target scores corresponding to probability estimates of a sample
belonging to a particular class
belonging to a particular class.

average : {'macro', 'weighted'}, default='macro'
Determines the type of averaging performed on the pairwise binary
metric scores
metric scores:
``'macro'``:
Calculate metrics for each label, and find their unweighted
mean. This does not take label imbalance into account. Classes
Expand All @@ -170,7 +170,7 @@ def _average_multiclass_ovo_score(binary_metric, y_true, y_score,
Returns
-------
score : float
Average of the pairwise binary metric scores
Average of the pairwise binary metric scores.
"""
check_consistent_length(y_true, y_score)

Expand Down
Loading
0