{"action":"created","issue":{"url":"https://api.github.com/repos/pavanramkumar/pyglmnet/issues/158","repository_url":"https://api.github.com/repos/pavanramkumar/pyglmnet","labels_url":"https://api.github.com/repos/pavanramkumar/pyglmnet/issues/158/labels{/name}","comments_url":"https://api.github.com/repos/pavanramkumar/pyglmnet/issues/158/comments","events_url":"https://api.github.com/repos/pavanramkumar/pyglmnet/issues/158/events","html_url":"https://github.com/pavanramkumar/pyglmnet/issues/158","id":180757624,"number":158,"title":"make GLM object play nice with sklearn's GridSearchCV","user":{"login":"themantalope","id":7599879,"avatar_url":"https://avatars.githubusercontent.com/u/7599879?v=3","gravatar_id":"","url":"https://api.github.com/users/themantalope","html_url":"https://github.com/themantalope","followers_url":"https://api.github.com/users/themantalope/followers","following_url":"https://api.github.com/users/themantalope/following{/other_user}","gists_url":"https://api.github.com/users/themantalope/gists{/gist_id}","starred_url":"https://api.github.com/users/themantalope/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/themantalope/subscriptions","organizations_url":"https://api.github.com/users/themantalope/orgs","repos_url":"https://api.github.com/users/themantalope/repos","events_url":"https://api.github.com/users/themantalope/events{/privacy}","received_events_url":"https://api.github.com/users/themantalope/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-03T21:57:34Z","updated_at":"2016-10-03T22:35:46Z","closed_at":null,"body":"Currently the`GLM` object does not return the proper variable types at various stages of the `sklearn GridSearchCV` lifecycle. I'll start with some of the issues I have had and the solutions that I worked on thus far on my forked version of the project.\r\n\r\n1) `GLM` object did not have a `set_params` function.\r\n\r\nAt line 180 of `pyglmnet.py` I added the following code:\r\n\r\n```python\r\ndef set_params(self, **parameters):\r\n    \"\"\"\r\n    Method for setting class parameters, as required by scikit-learn's\r\n    GridSearchCV. See\r\n    http://scikit-learn.org/stable/developers/contributing.html#get-params-and-set-params\r\n    for more details.\r\n    \"\"\"\r\n    for parameter, value in parameters.items():\r\n        setattr(self, parameter, value)\r\n```\r\nThis method is required for `GridSearchCV` to set the current parameters within the grid search."},"comment":{"url":"https://api.github.com/repos/pavanramkumar/pyglmnet/issues/comments/251247161","html_url":"https://github.com/pavanramkumar/pyglmnet/issues/158#issuecomment-251247161","issue_url":"https://api.github.com/repos/pavanramkumar/pyglmnet/issues/158","id":251247161,"user":{"login":"themantalope","id":7599879,"avatar_url":"https://avatars.githubusercontent.com/u/7599879?v=3","gravatar_id":"","url":"https://api.github.com/users/themantalope","html_url":"https://github.com/themantalope","followers_url":"https://api.github.com/users/themantalope/followers","following_url":"https://api.github.com/users/themantalope/following{/other_user}","gists_url":"https://api.github.com/users/themantalope/gists{/gist_id}","starred_url":"https://api.github.com/users/themantalope/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/themantalope/subscriptions","organizations_url":"https://api.github.com/users/themantalope/orgs","repos_url":"https://api.github.com/users/themantalope/repos","events_url":"https://api.github.com/users/themantalope/events{/privacy}","received_events_url":"https://api.github.com/users/themantalope/received_events","type":"User","site_admin":false},"created_at":"2016-10-03T22:35:46Z","updated_at":"2016-10-03T22:35:46Z","body":"3) `GLM` object's score method returns an array\r\n\r\n`GridSearchCV` expects that the score function returns a scalar, since the general pattern of the `GridSearchCV` is to set parameters, train the model given the parameter set and data and return one score for model/parameter comparison. Currently, the `GLM` object's `score` function returns an array of scores (for the given lambdas). A _very_ hackish solution I had for this was the following at the end of the `score` function:\r\n\r\n```python\r\nif isinstance(score, numbers.Number):\r\n            return score\r\n        else:\r\n            return np.array(score)\r\n```\r\n\r\nThis still doesn't get around the problem that if one uses a scoring metric other than `pseudo_R2` (based on my current understanding of the code) then it's possible that this function would return something other than a scalar."}}
{"actor":{"display_login":"themantalope"}}