Skip to content

ENH: Add incremental algorithms support #160

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add condition for finalize
  • Loading branch information
olegkkruglov committed Sep 25, 2024
commit 9461fad69a00ecbf69a3e5fcef662fb1bafd4253
12 changes: 8 additions & 4 deletions sklbench/benchmarks/sklearn_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,27 +347,31 @@ def ndarray_function(x, y):
x[i * batch_size : (i + 1) * batch_size],
y[i * batch_size : (i + 1) * batch_size],
)
estimator_instance._onedal_finalize_fit()
if hasattr(estimator_instance, "_onedal_finalize_fit"):
estimator_instance._onedal_finalize_fit()

def dataframe_function(x, y):
for i in range(n_batches):
method_instance(
x.iloc[i * batch_size : (i + 1) * batch_size],
y.iloc[i * batch_size : (i + 1) * batch_size],
)
estimator_instance._onedal_finalize_fit()
if hasattr(estimator_instance, "_onedal_finalize_fit"):
estimator_instance._onedal_finalize_fit()

else:

def ndarray_function(x):
for i in range(n_batches):
method_instance(x[i * batch_size : (i + 1) * batch_size])
estimator_instance._onedal_finalize_fit()
if hasattr(estimator_instance, "_onedal_finalize_fit"):
estimator_instance._onedal_finalize_fit()

def dataframe_function(x):
for i in range(n_batches):
method_instance(x.iloc[i * batch_size : (i + 1) * batch_size])
estimator_instance._onedal_finalize_fit()
if hasattr(estimator_instance, "_onedal_finalize_fit"):
estimator_instance._onedal_finalize_fit()
Comment on lines +364 to +365
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it necessary to call finalize_fit? wouldn't this happen automatically? we specifically have flexibly logic here (ie use of method_instance variable) so let's avoid specific calls if possible

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finalize_fit is called if any result attribute has been called. only partial_fit would be measured here without this call


if "ndarray" in str(type(data_args[0])):
return ndarray_function
Expand Down