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

Added Event Segmentation class, along with example and tests #72

Merged
merged 1 commit into from Aug 29, 2016

Conversation

Projects
None yet
4 participants
@cbaldassano
Collaborator

cbaldassano commented Jul 19, 2016

Added event segmentation based on a hidden markov model. The paper describing this method is currently being written and will be published as a preprint within the next couple months.

@buildbot-princeton

This comment has been minimized.

Show comment
Hide comment
@buildbot-princeton

buildbot-princeton Jul 19, 2016

Collaborator

Can one of the admins verify this patch?

Collaborator

buildbot-princeton commented Jul 19, 2016

Can one of the admins verify this patch?

1 similar comment
@buildbot-princeton

This comment has been minimized.

Show comment
Hide comment
@buildbot-princeton

buildbot-princeton Jul 19, 2016

Collaborator

Can one of the admins verify this patch?

Collaborator

buildbot-princeton commented Jul 19, 2016

Can one of the admins verify this patch?

@mihaic

This comment has been minimized.

Show comment
Hide comment
@mihaic

mihaic Jul 19, 2016

Contributor

Add to whitelist.

Contributor

mihaic commented Jul 19, 2016

Add to whitelist.

Show outdated Hide outdated brainiak/event_seg/event.py Outdated
Show outdated Hide outdated brainiak/event_seg/event.py Outdated
Show outdated Hide outdated brainiak/event_seg/event.py Outdated
Show outdated Hide outdated brainiak/event_seg/event.py Outdated
Show outdated Hide outdated brainiak/event_seg/event.py Outdated
Show outdated Hide outdated tests/event_seg/test_event.py Outdated
@mihaic

This comment has been minimized.

Show comment
Hide comment
@mihaic

mihaic Jul 20, 2016

Contributor

It seems like you are close to implementing the scikit-learn Estimator and Predictor interfaces:
http://scikit-learn.org/stable/developers/contributing.html#apis-of-scikit-learn-objects

You should rename your learn_events method to fit and your find_events method to predict. Furthermore, you should add a trailing underscore to all data-dependent attributes set after fitting the model and not set them (even to None) outside fit:
http://scikit-learn.org/stable/developers/contributing.html#estimated-attributes

Contributor

mihaic commented Jul 20, 2016

It seems like you are close to implementing the scikit-learn Estimator and Predictor interfaces:
http://scikit-learn.org/stable/developers/contributing.html#apis-of-scikit-learn-objects

You should rename your learn_events method to fit and your find_events method to predict. Furthermore, you should add a trailing underscore to all data-dependent attributes set after fitting the model and not set them (even to None) outside fit:
http://scikit-learn.org/stable/developers/contributing.html#estimated-attributes

@mihaic

This comment has been minimized.

Show comment
Hide comment
@mihaic

mihaic Jul 20, 2016

Contributor

Please remove the underscore from the subpackage name, as we did with PR #73.

Contributor

mihaic commented Jul 20, 2016

Please remove the underscore from the subpackage name, as we did with PR #73.

Show outdated Hide outdated examples/event_seg/simulated_data.py Outdated
@mihaic

This comment has been minimized.

Show comment
Hide comment
@mihaic

mihaic Jul 25, 2016

Contributor

@cbaldassano Could you please name someone who is knowledgeable about your project, either from PNI or Intel?

Contributor

mihaic commented Jul 25, 2016

@cbaldassano Could you please name someone who is knowledgeable about your project, either from PNI or Intel?

Added Event Segmentation class, along with example and tests
Making changes based on pull request comments, including implementing the sklearn Estimator interface

Improved simulated data example,  added sklearn validation test, added correctness test. Final commit before rebase.

Adding nose requirement and fixing docstrings

Removed sklearn tests

Fixed functions that were modifying their arguments, and added clarifying comments

Fixed docstrings
@cbaldassano

This comment has been minimized.

Show comment
Hide comment
@cbaldassano

cbaldassano Aug 5, 2016

Collaborator

I've made all the requested changes! @lcnature agreed last week to help review this code - Mingbo, I will send you the preprint describing the method to help you understand what it is supposed to be doing.

Collaborator

cbaldassano commented Aug 5, 2016

I've made all the requested changes! @lcnature agreed last week to help review this code - Mingbo, I will send you the preprint describing the method to help you understand what it is supposed to be doing.

Show outdated Hide outdated requirements-dev.txt Outdated
@mihaic

This comment has been minimized.

Show comment
Hide comment
@mihaic

mihaic Aug 9, 2016

Contributor

@cbaldassano Have you sent Mingbo the preprint? Actually, are you considering publishing it on Arxiv or a similar place? If you are you could cite it in a docstring.

Contributor

mihaic commented Aug 9, 2016

@cbaldassano Have you sent Mingbo the preprint? Actually, are you considering publishing it on Arxiv or a similar place? If you are you could cite it in a docstring.

@cbaldassano

This comment has been minimized.

Show comment
Hide comment
@cbaldassano

cbaldassano Aug 9, 2016

Collaborator

Yes, Mingbo has the preprint and said he will review the code soon. We'll be posting it on bioRxiv in a month or so, after we make some revisions, so maybe I'll submit a tiny pull request at that time to add the reference in the docstring.

Collaborator

cbaldassano commented Aug 9, 2016

Yes, Mingbo has the preprint and said he will review the code soon. We'll be posting it on bioRxiv in a month or so, after we make some revisions, so maybe I'll submit a tiny pull request at that time to add the reference in the docstring.

X = [X]
n_train = len(X)
for i in range(n_train):

This comment has been minimized.

@lcnature

lcnature Aug 25, 2016

Contributor

I wonder if this can be avoided, e.g., by making copy of X and transpose the copy?
Because X is passed as reference, this line and line 118 which modify X will modify the data X outside the scope of this function, which might be unexpected by the user. For example, if a user wants to fit the data for multiple times, each time trying a different choice of K, (s)he might find the data has been modified after each time of fitting.

@lcnature

lcnature Aug 25, 2016

Contributor

I wonder if this can be avoided, e.g., by making copy of X and transpose the copy?
Because X is passed as reference, this line and line 118 which modify X will modify the data X outside the scope of this function, which might be unexpected by the user. For example, if a user wants to fit the data for multiple times, each time trying a different choice of K, (s)he might find the data has been modified after each time of fitting.

This comment has been minimized.

@cbaldassano

cbaldassano Aug 26, 2016

Collaborator

Very good point - I'll only modify copies.

@cbaldassano

cbaldassano Aug 26, 2016

Collaborator

Very good point - I'll only modify copies.

Show outdated Hide outdated brainiak/eventseg/event.py Outdated
Show outdated Hide outdated brainiak/eventseg/event.py Outdated
Show outdated Hide outdated brainiak/eventseg/event.py Outdated
log_alpha[t] -= log_scale[t]
# Backward pass
log_beta[-1, :] = self._log(self.p_end) - log_scale[-1]

This comment has been minimized.

@lcnature

lcnature Aug 25, 2016

Contributor

log_scale was calculated based on log_alpha in line 255, but not recalculated here based on log_beta, but it . I wonder if you need to do something similar as in line 255-256 but for log_beta. But since line 270 directly uses the log_scale calculated in line 255, perhaps you actually did not want to include anything from the backward pass in the ll? Sorry I do not know much of the forward-backward algorithm.

@lcnature

lcnature Aug 25, 2016

Contributor

log_scale was calculated based on log_alpha in line 255, but not recalculated here based on log_beta, but it . I wonder if you need to do something similar as in line 255-256 but for log_beta. But since line 270 directly uses the log_scale calculated in line 255, perhaps you actually did not want to include anything from the backward pass in the ll? Sorry I do not know much of the forward-backward algorithm.

This comment has been minimized.

@cbaldassano

cbaldassano Aug 26, 2016

Collaborator

This is actually correct, though I agree it looks asymmetrical. I'll add a link to the wikipedia page which explains what's going on with the log_scale parameter (called c_t on wiki) https://en.wikipedia.org/wiki/Forward%E2%80%93backward_algorithm

@cbaldassano

cbaldassano Aug 26, 2016

Collaborator

This is actually correct, though I agree it looks asymmetrical. I'll add a link to the wikipedia page which explains what's going on with the log_scale parameter (called c_t on wiki) https://en.wikipedia.org/wiki/Forward%E2%80%93backward_algorithm

@mihaic

This comment has been minimized.

Show comment
Hide comment
@mihaic

mihaic Aug 26, 2016

Contributor

@lcnature Are you happy with this PR?

Contributor

mihaic commented Aug 26, 2016

@lcnature Are you happy with this PR?

Show outdated Hide outdated brainiak/eventseg/__init__.py Outdated
Show outdated Hide outdated brainiak/eventseg/event.py Outdated
@lcnature

This comment has been minimized.

Show comment
Hide comment
@lcnature

lcnature Aug 28, 2016

Contributor

@mihaic @cbaldassano
Sorry for the delay. I am happy with all the changes 👍

Contributor

lcnature commented Aug 28, 2016

@mihaic @cbaldassano
Sorry for the delay. I am happy with all the changes 👍

@mihaic mihaic merged commit 68f04d5 into brainiak:master Aug 29, 2016

3 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
linux Build finished.
Details
macos Build finished.
Details
@mihaic

This comment has been minimized.

Show comment
Hide comment
@mihaic

mihaic Aug 29, 2016

Contributor

Thank you very much for your contribution, @cbaldassano. And thanks for the review, @lcnature.

Contributor

mihaic commented Aug 29, 2016

Thank you very much for your contribution, @cbaldassano. And thanks for the review, @lcnature.

danielsuo pushed a commit that referenced this pull request Nov 16, 2017

Fix bug in serializing arguments of tasks that are more complex objec…
…ts (#72)

* Give more informative error message when we do not know how to serialize a class.

* Check that passing arguments to remote functions and getting them does not change their values.

* fix serialization bug

* fix tests for common module

* Formatting.

* Bug fix in init_pickle_module signature.

* Use pickle with HIGHEST_PROTOCOL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment