Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Added predict_proba to logistic regression and added the appropriate unit test #1

Merged
merged 2 commits into from
Nov 25, 2015

Conversation

cbonnett
Copy link
Contributor

Well, the title says it all really.
Thought this might be useful.

@@ -117,6 +117,15 @@ def predict(self, X):
return pred
return pred.argmax(axis=1)

def predict_proba(self, X):
pred = self._session.run(self._model.predictions,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to move the _session.run part to def _predict function to have only once and share between predict and predict_proba

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean, and would make sense. Not sure how to technically implement it though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like this:

def _predict(self, X):
    return self._session.run(self._model.predictions, feed_dict={ .. })

def predict(self, X):
    pred = self._predict(X)
    if self.n_classes < 2:
       return pred
    return pred.argmax(axis=1)

def predict_proba(self, X):
     return self._predict(X)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll merge yours in and will implement the suggestion from above as I'm also adding scoring with mini batches and streaming and will close this PR. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants