10000 DOC Ensures that sklearn.base.clone passes numpydoc validation by kkatottn · Pull Request #21557 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC Ensures that sklearn.base.clone passes numpydoc validation #21557

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 5 commits into from
Nov 22, 2021
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
1 change: 0 additions & 1 deletion maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
numpydoc_validation = pytest.importorskip("numpydoc.validate")

FUNCTION_DOCSTRING_IGNORE_LIST = [
"sklearn.base.clone",
"sklearn.cluster._affinity_propagation.affinity_propagation",
"sklearn.cluster._kmeans.kmeans_plusplus",
"sklearn.cluster._mean_shift.estimate_bandwidth",
Expand Down
25 changes: 15 additions & 10 deletions sklearn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,34 @@


def clone(estimator, *, safe=True):
"""Constructs a new unfitted estimator with the same parameters.
"""Construct a new unfitted estimator with the same parameters.

Clone does a deep copy of the model in an estimator
without actually copying attached data. It yields a new estimator
without actually copying attached data. It returns a new estimator
with the same parameters that has not been fitted on any data.

If the estimator's `random_state` parameter is an integer (or if the
estimator doesn't have a `random_state` parameter), an *exact clone* is
returned: the clone and the original estimator will give the exact same
results. Otherwise, *statistical clone* is returned: the clone might
yield different results from the original estimator. More details can be
found in :ref:`randomness`.

Parameters
----------
estimator : {list, tuple, set} of estimator instance or a single \
estimator instance
The estimator or group of estimators to be cloned.

safe : bool, default=True
If safe is False, clone will fall back to a deep copy on objects
that are not estimators.

Returns
-------
estimator : object
The deep copy of the input, an estimator if input is an estimator.

Notes
-----
If the estimator's `random_state` parameter is an integer (or if the
estimator doesn't have a `random_state` parameter), an *exact clone* is
returned: the clone and the original estimator will give 62A3 the exact same
results. Otherwise, *statistical clone* is returned: the clone might
return different results from the original estimator. More details can be
found in :ref:`randomness`.
"""
estimator_type = type(estimator)
# XXX: not handling dictionaries
Expand Down
0