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

Remove Implicit NumPy Conversion in BaseSearchCV (#849) #915

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 7 additions & 6 deletions dask_ml/model_selection/_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ def do_fit(
out_append = out.append

for X, y, t, p in zip(Xs, ys, tokens, params):
if (X, y, t) in seen:
out_append(seen[X, y, t])
if (id(X), id(y), t) in seen:
out_append(seen[id(X), id(y), t])
else:
for n, fit_params in n_and_fit_params:
dsk[(fit_name, m, n)] = (
Expand All @@ -492,7 +492,7 @@ def do_fit(
p,
fit_params,
)
seen[(X, y, t)] = (fit_name, m)
seen[(id(X), id(y), t)] = (fit_name, m)
out_append((fit_name, m))
m += 1

Expand Down Expand Up @@ -565,8 +565,8 @@ def do_fit_transform(
out_append = out.append

for X, y, t, p in zip(Xs, ys, tokens, params):
if (X, y, t) in seen:
out_append(seen[X, y, t])
if (id(X), id(y), t) in seen:
out_append(seen[id(X), id(y), t])
else:
for n, fit_params in n_and_fit_params:
dsk[(fit_Xt_name, m, n)] = (
Expand All @@ -581,7 +581,7 @@ def do_fit_transform(
)
dsk[(fit_name, m, n)] = (getitem, (fit_Xt_name, m, n), 0)
dsk[(Xt_name, m, n)] = (getitem, (fit_Xt_name, m, n), 1)
seen[X, y, t] = m
seen[id(X), id(y), t] = m
out_append(m)
m += 1

Expand Down Expand Up @@ -665,6 +665,7 @@ def _do_fit_step(
# Extract the proper subset of Xs, ys
sub_Xs = get(ids, Xs)
sub_ys = get(ids, ys)

# Only subset the parameters/tokens if necessary
if sub_fields:
sub_tokens = list(pluck(sub_inds, get(ids, tokens)))
Expand Down
5 changes: 4 additions & 1 deletion dask_ml/model_selection/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def to_keys(dsk, *args):
for x in args:
if x is None:
yield None
elif isinstance(x, (da.Array, dd.DataFrame)):
elif isinstance(x, da.Array):
dsk.update(x.dask)
yield x
elif isinstance(x, dd.DataFrame):
x = delayed(x)
dsk.update(x.dask)
yield x.key
Expand Down