added a new file with the vectorized version of logistic model#4
Open
Leo-Laurent wants to merge 3 commits intomasterfrom
Open
added a new file with the vectorized version of logistic model#4Leo-Laurent wants to merge 3 commits intomasterfrom
Leo-Laurent wants to merge 3 commits intomasterfrom
Conversation
zermelozf
approved these changes
Jun 15, 2020
Member
zermelozf
left a comment
There was a problem hiding this comment.
Overall pretty good.
Spaces around operators should be reviewed a little bit.
Also, one minor improvement could be to extract the history of loss and values outside of the gradient function for more flexibility. You can have a look at what's done there: https://github.com/zermelozf/notebooks/blob/master/First%20order%20optimization.ipynb
|
|
||
|
|
||
| def probability_y(x, y, theta): # array of P( Y=y[k] | x[k] ) | ||
| return 1 / (1 + np.exp(-y*x.dot(theta))) |
Member
There was a problem hiding this comment.
Please add spaces between the * and the terms.
|
|
||
|
|
||
| def generate_y(x, theta): | ||
| return np.sign(2/(1 + np.exp(-x.dot(theta))) - 1) |
Member
There was a problem hiding this comment.
Please add spaces around the /
| def generate_real_x(n, theta): | ||
| dict_frequencies = word_frequencies_dictionary() | ||
| n = min(n, len(dict_frequencies)) | ||
| x = np.array([[0., 1.]]*n) |
|
|
||
|
|
||
| def logistic_error(x, y, theta): | ||
| return - np.sum(np.log(probability_y(x, y, theta))) |
Member
There was a problem hiding this comment.
no need for space here after -
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.