Skip to content

Added utils.gen_batches in documentation, Solving issue #19681 #19688

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 20 commits into from
Mar 17, 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
3 changes: 3 additions & 0 deletions doc/developers/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ Helper Functions
to ``n``. Used in :func:`~sklearn.decomposition.dict_learning` and
:func:`~sklearn.cluster.k_means`.

- :class:`gen_batches`: generator to create slices containing batch size elements
from 0 to ``n``

- :func:`safe_mask`: Helper function to convert a mask to the format expected
by the numpy array or scipy sparse matrix on which to use it (sparse
matrices support integer indices only while numpy arrays support both
Expand Down
1 change: 1 addition & 0 deletions doc/modules/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,7 @@ Plotting
utils.extmath.fast_logdet
utils.extmath.density
utils.extmath.weighted_mode
utils.gen_batches
utils.gen_even_slices
utils.graph.single_source_shortest_path_length
utils.graph_shortest_path.graph_shortest_path
Expand Down
9 changes: 9 additions & 0 deletions sklearn/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,10 @@ def gen_batches(n, batch_size, *, min_batch_size=0):
------
slice of batch_size elements

See Also
--------
gen_even_slices: Generator to create n_packs slices going up to n.

Examples
--------
>>> from sklearn.utils import gen_batches
Expand Down Expand Up @@ -740,6 +744,11 @@ def gen_even_slices(n, n_packs, *, n_samples=None):
------
slice

See Also
--------
gen_batches: Generator to create slices containing batch_size elements
from 0 to n.

Examples
--------
>>> from sklearn.utils import gen_even_slices
Expand Down