Uh oh!
There was an error while loading. Please reload this page.
[SPARK-17116][Pyspark] Allow parameters to be {string,value} dict at runtime - #15871
[SPARK-17116][Pyspark] Allow parameters to be {string,value} dict at runtime#15871aditya1702 wants to merge 1 commit into
Conversation
@srowen@jaceklaskowski Could you take a look and check if this improvement is proper? Since this is my first contribution it might have some issues. 😅 |
AmplabJenkins
commented
Nov 13, 2016
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Shouldn't we just use isinstance instead?
There was a problem hiding this comment.
@HyukjinKwon I tried using isinstance(type(params.keys()[0],str) but it returned False. And why cant we directly check if it is a str or not?
There was a problem hiding this comment.
Ah, I meant, isinstance(params.keys()[0], str). Direct type comparison does not take care of subclasses. I believe it is a common pattern to check the types. For example,
>>>classA(str):
... pass
...
>>>isinstance(A(), str)
True>>>type(A()) isstrFalseThis might be a major problem in a way, for example, when you give an argument as OrderedDict which extends dict.
Another reason is consistency across codebase. I believe isinstance is more widely used in the codes.
HyukjinKwon
commented
Nov 14, 2016
I think we need a test here maybe and update the argument description if this change is legitimate. |
HyukjinKwon
commented
Nov 14, 2016
cc @holdenk |
aditya1702
commented
Nov 14, 2016
@HyukjinKwon this is my first time with contributing in Spark and so I didnt know if we add tests to each pull. If it is proper I will add the tests :) |
@HyukjinKwon@holdenk@srowen I have updated the code. Could you please take a look |
| for param, value in params.items(): | ||
| p = getattr(self, param) | ||
| param_new.update({p: value}) | ||
| params=param_new |
There was a problem hiding this comment.
Could we just make it just like the one as below?
params=dict([(getattr(self, p), v) forp, vinparams.items()])BTW, I am not supposed to decide what should be added into Spark. We can wait for committer's review :)
holdenk
commented
Nov 15, 2016
Thanks for working on this! So at first glance I'm not super sure if we want to add this (is this being done to be more closely related to the skicitlearn apis or something?) A good next step would probably be adding some tests for this as well :) Once we've got some tests we can ping some of the Python ML people and see what they think. |
aditya1702
commented
Nov 15, 2016
@holdenk Sure. I will add the tests. I saw that as per the issue opened the setParams was taking in string dict while fit() method was not. Hence I thought it would be an improvement to do that to the fit() method as well. |
holdenk
commented
Nov 26, 2016
@aditya1702 - thanks that sounds like a good reason for us to be consistent between the two. Let me know how adding the tests goes :) |
HyukjinKwon
commented
Feb 9, 2017
Hi @aditya1702, do you mind if I ask whether you are still working on this? Maybe it should be closed for now if you are currently not able to work on this further. It seems inactive for few months. |
## What changes were proposed in this pull request? This PR proposes to close stale PRs. What I mean by "stale" here includes that there are some review comments by reviewers but the author looks inactive without any answer to them more than a month. I left some comments roughly a week ago to ping and the author looks still inactive in these PR below These below includes some PR suggested to be closed and a PR against another branch which seems obviously inappropriate. Given the comments in the last three PRs below, they are probably worth being taken over by anyone who is interested in it. Closesapache#7963Closesapache#8374Closesapache#11192Closesapache#11374Closesapache#11692Closesapache#12243Closesapache#12583Closesapache#12620Closesapache#12675Closesapache#12697Closesapache#12800Closesapache#13715Closesapache#14266Closesapache#15053Closesapache#15159Closesapache#15209Closesapache#15264Closesapache#15267Closesapache#15871Closesapache#15861Closesapache#16319Closesapache#16324Closesapache#16890Closesapache#12398Closesapache#12933Closesapache#14517 ## How was this patch tested? N/A Author: hyukjinkwon <gurwls223@gmail.com> Closesapache#16937 from HyukjinKwon/stale-prs-close.
What changes were proposed in this pull request?
This pull allows a dictionary containing string as keys to be passed in the fit() method. Presently it only allows an instance of the Estimator to be passed as key.
How was this patch tested?
This patch was manually tested on a local PC.