Skip to content
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

Minor fixes to docs #473

Merged
merged 2 commits into from
Nov 20, 2024
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
2 changes: 1 addition & 1 deletion doc/tutorials_src/model_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
# In this case, the scores haven't actually been computed yet (hence the
# "delayed" term). Instead, Verde scheduled the operations with Dask. Since we
# are interested only in the mean score, we can schedule the mean as well using
# :func:`dask.delayed`:
# :func:`dask.delayed.delayed`:

mean_score = dask.delayed(np.mean)(scores)
print("Delayed mean:", mean_score)
Expand Down
8 changes: 4 additions & 4 deletions doc/tutorials_src/model_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@

###############################################################################
# Unlike :func:`verde.cross_val_score`, calling :meth:`~verde.SplineCV.fit`
# does **not** result in :func:`dask.delayed` objects. The full grid search is
# executed and the optimal parameters are found immediately.
# does **not** result in :func:`dask.delayed.delayed` objects. The full grid
# search is executed and the optimal parameters are found immediately.

spline.fit(proj_coords, data.air_temperature_c)

print("Best damping:", spline.damping_)

###############################################################################
# The one caveat is the that the ``scores_`` attribute will be a list of
# :func:`dask.delayed` objects instead because the scores are only computed as
# intermediate values in the scheduled computations.
# :func:`dask.delayed.delayed` objects instead because the scores are only
# computed as intermediate values in the scheduled computations.

print("Delayed scores:", spline.scores_)

Expand Down
6 changes: 3 additions & 3 deletions verde/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def scatter_points(region, size, random_state=None, extra_coords=None):
permutations. Use a fixed seed to make sure computations are
reproducible. Use ``None`` to choose a seed automatically (resulting in
different numbers with each run).
extra_coords : None, scalar, or list
extra_coords : None, scalar or list
If not None, then value(s) of extra coordinate arrays to be generated.
These extra arrays will have the same *size* as the others but will
contain a constant value. Will generate an extra array per value given
Expand Down Expand Up @@ -331,7 +331,7 @@ def grid_coordinates(
instead of the grid lines. In practice, this means that there will be
one less element per dimension of the grid when compared to grid line
registered (only if given *spacing* and not *shape*). Default is False.
extra_coords : None, scalar, or list
extra_coords : None, scalar or list
If not None, then value(s) of extra coordinate arrays to be generated.
These extra arrays will have the same *shape* as the others but will
contain a constant value. Will generate an extra array per value given
Expand Down Expand Up @@ -709,7 +709,7 @@ def profile_coordinates(point1, point2, size, extra_coords=None):
second point, respectively.
size : int
Number of points to sample along the line.
extra_coords : None, scalar, or list
extra_coords : None, scalar or list
If not None, then value(s) of extra coordinate arrays to be generated.
These extra arrays will have the same *size* as the others but will
contain a constant value. Will generate an extra array per value given
Expand Down
23 changes: 12 additions & 11 deletions verde/model_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class BlockShuffleSplit(BaseBlockCrossValidator):
absolute number of test samples. If None, the value is set to the
complement of the train size. If ``train_size`` is also None, it will
be set to 0.1.
train_size : float, int, or None, default=None
train_size : float, int or None, default=None
If float, should be between 0.0 and 1.0 and represent the
proportion of the dataset to include in the train split. If
int, represents the absolute number of train samples. If None,
Expand Down Expand Up @@ -605,11 +605,11 @@ def cross_val_score(
scoring function (e.g., mean square error, mean absolute error, etc).

Can optionally run in parallel using :mod:`dask`. To do this, use
``delayed=True`` to dispatch computations with :func:`dask.delayed` instead
of running them. The returned scores will be "lazy" objects instead of the
actual scores. To trigger the computation (which Dask will run in parallel)
call the `.compute()` method of each score or :func:`dask.compute` with the
entire list of scores.
``delayed=True`` to dispatch computations with :func:`dask.delayed.delayed`
instead of running them. The returned scores will be "lazy" objects instead
of the actual scores. To trigger the computation (which Dask will run in
parallel) call the `.compute()` method of each score or
:func:`dask.compute` with the entire list of scores.

.. warning::

Expand Down Expand Up @@ -639,11 +639,12 @@ def cross_val_score(
be a dask ``Client`` object. It will be used to dispatch computations
to the dask cluster.
delayed : bool
If True, will use :func:`dask.delayed` to dispatch computations without
actually executing them. The returned scores will be a list of delayed
objects. Call `.compute()` on each score or :func:`dask.compute` on the
entire list to trigger the actual computations.
scoring : None, str, or callable
If True, will use :func:`dask.delayed.delayed` to dispatch computations
without actually executing them. The returned scores will be a list of
delayed objects. Call `.compute()` on each score or
:func:`dask.compute` on the entire list to trigger the actual
computations.
scoring : None, str or callable
A scoring function (or name of a function) known to scikit-learn. See
the description of *scoring* in
:func:`sklearn.model_selection.cross_val_score` for details. If None,
Expand Down
20 changes: 10 additions & 10 deletions verde/spline.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ class SplineCV(BaseGridder):
(or minimum) mean cross-validation score (i.e., a grid search).

This can optionally run in parallel using :mod:`dask`. To do this, use
``delayed=True`` to dispatch computations with :func:`dask.delayed`.
In this case, each fit and score operation of the grid search will be
performed in parallel.
``delayed=True`` to dispatch computations with
:func:`dask.delayed.delayed`. In this case, each fit and score
operation of the grid search will be performed in parallel.

.. note::

When using *delayed*, the ``scores_`` attribute will be
:func:`dask.delayed` objects instead of the actual scores. This is
because the scores are an intermediate step in the computations and
:func:`dask.delayed.delayed` objects instead of the actual scores. This
is because the scores are an intermediate step in the computations and
their results are not stored. If you need the scores, run
:func:`dask.compute` on ``scores_`` to calculate them. Be warned that
**this will run the grid search again**. It might still be faster than
Expand Down Expand Up @@ -91,10 +91,10 @@ class SplineCV(BaseGridder):
be a dask ``Client`` object. It will be used to dispatch computations
to the dask cluster.
delayed : bool
If True, will use :func:`dask.delayed` to dispatch computations and
allow mod:`dask` to execute the grid search in parallel (see note
If True, will use :func:`dask.delayed.delayed` to dispatch computations
and allow mod:`dask` to execute the grid search in parallel (see note
above).
scoring : None, str, or callable
scoring : None, str or callable
The scoring function (or name of a function) used for cross-validation.
Must be known to scikit-learn. See the description of *scoring* in
:func:`sklearn.model_selection.cross_val_score` for details. If None,
Expand All @@ -115,8 +115,8 @@ class SplineCV(BaseGridder):
methods.
scores_ : array
The mean cross-validation score for each parameter combination. If
``delayed=True``, will be a list of :func:`dask.delayed` objects (see
note above).
``delayed=True``, will be a list of :func:`dask.delayed.delayed`
objects (see note above).
mindist_ : float
The optimal value for the *mindist* parameter.
damping_ : float
Expand Down
2 changes: 1 addition & 1 deletion verde/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def dispatch(function, delayed=False, client=None):
function : callable
The function that will be called.
delayed : bool
If True, will wrap the function in :func:`dask.delayed`.
If True, will wrap the function in :func:`dask.delayed.delayed`.
client : None or dask.distributed Client
If *delayed* is False and *client* is not None, will return a partial
execution of the ``client.submit`` with the function as first argument.
Expand Down