-
Notifications
You must be signed in to change notification settings - Fork 514
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
[REVIEW] Converting all Estimator Constructors to Keyword Arguments #3636
[REVIEW] Converting all Estimator Constructors to Keyword Arguments #3636
Conversation
…deprecation message decorator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very cool! I had only minor questions and comments, can wrap up quickly. If this is ready to go, can you remove the WIP label?
python/cuml/common/input_utils.py
Outdated
@@ -609,3 +613,70 @@ def sparse_scipy_to_cp(sp, dtype): | |||
v = cp.asarray(values, dtype=dtype) | |||
|
|||
return cupyx.scipy.sparse.coo_matrix((v, (r, c)), sp.shape) | |||
|
|||
|
|||
class _deprecate_pos_args: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you benchmark a class initialization with and without this change? (just %timeit x = Foo()
in Ipython) I think it'll be very small but just want to make sure there is not a meaningful cost to the tricks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are the numbers. Before this PR:
>>> timeit.repeat('cuml.DBSCAN()', 'import cuml', number=100000)
[1.6759078549985134, 0.41760462100137374, 0.4198731740034418, 0.4204189170013706, 0.4161926310007402]
After this PR:
>>> timeit.repeat('cuml.DBSCAN()', 'import cuml', number=100000)
[2.557721577999473, 0.7288761550007621, 0.7315405129993451, 0.7273198049988423, 0.7297004659994855]
I was surprised that the impact would be so big (75% longer) but at the same time this is only adding 3 usec per instantiation which is incredibly small. I'm not sure what we could change in the function to make it run faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just had a quick comment
Codecov Report
@@ Coverage Diff @@
## branch-0.19 #3636 +/- ##
===============================================
+ Coverage 80.70% 82.38% +1.67%
===============================================
Files 227 227
Lines 17615 17652 +37
===============================================
+ Hits 14217 14542 +325
+ Misses 3398 3110 -288
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@dantegd and @JohnZed I've incorporated your feedback into this PR and merged upstream. However, with the changes to the To address both of your comments about the local import, I've moved the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I like the new namings and appreciate the move to internals. I'll wait a bit before merging in case @dantegd wants to take a look at the changes
@gpucibot merge |
Closes #3373
This mimics sklearn's positional argument deprecation message (and is named differently to prevent mixups) but is automatically added to any class that inherits from
cuml.Base
(similar to otherCumlArray
decorators that are automatically added toBase
class). When the descriptor is automatically added, it assumes all arguments should be keyword-only (to catch accidentally forgetting to specify keyword only arguments). This can easily be overridden by manually adding the decorator if some arguments need to be positional and some keyword. For example, theOneVsRestClassifier
estimator takes a positional estimator to wrap so the__init__
function looks like:Notes:
__init__
functions but could be applied to any of the public functions in the API.