Skip to content
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

Accept prec_init as array or list #1616

Merged
merged 8 commits into from
Mar 1, 2021

Conversation

antonis19
Copy link
Contributor

@antonis19 antonis19 commented Oct 2, 2020

Description of proposed changes

Currently, LabelModel only accepts a float or an int for prec_init. These get converted into a 1D tensor of the same value. In this pull request, prec_init can be passed as np.ndarray or as a Python list also. This way different labeling functions can get assigned different priors.

Related issue(s)

Fixes #1484

Test plan

Checklist

Need help on these? Just ask!

  • [ ✅ ] I have read the CONTRIBUTING document.
  • [ ✅ ] I have updated the documentation accordingly.
  • [ ✅ ] I have added tests to cover my changes.
  • [ ✅ ] I have run tox -e complex and/or tox -e spark if appropriate.
  • [ ✅ ] All new and existing tests passed.

@codecov
Copy link

codecov bot commented Oct 2, 2020

Codecov Report

Merging #1616 (9c5f4bf) into master (ed77718) will increase coverage by 0.10%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##           master    #1616      +/-   ##
==========================================
+ Coverage   97.21%   97.31%   +0.10%     
==========================================
  Files          68       68              
  Lines        2151     2157       +6     
  Branches      345      348       +3     
==========================================
+ Hits         2091     2099       +8     
+ Misses         31       30       -1     
+ Partials       29       28       -1     
Impacted Files Coverage Δ
snorkel/labeling/model/label_model.py 96.30% <85.71%> (+0.76%) ⬆️

@ivelin ivelin mentioned this pull request Jan 15, 2021
Copy link
Member

@henryre henryre left a comment

Choose a reason for hiding this comment

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

Hi @antonis19 , thanks for the PR and apologies for the delay on reviewing. Added some comments. I'd also recommend updating the type of TrainConfig.prec_init to a union type that allows all of the types we're now handling.

snorkel/labeling/model/label_model.py Outdated Show resolved Hide resolved
snorkel/labeling/model/label_model.py Show resolved Hide resolved
test/labeling/model/test_label_model.py Outdated Show resolved Hide resolved
@antonis19
Copy link
Contributor Author

@henryre I took care of the comments you made. Now there seems to be a build error even though all the tests pass. It seems to me that these are errors related to the build configuration, or am I wrong?

Copy link
Member

@henryre henryre left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! Taking a look at the build error now

snorkel/labeling/model/label_model.py Outdated Show resolved Hide resolved
snorkel/labeling/model/label_model.py Outdated Show resolved Hide resolved
test/labeling/model/test_label_model.py Outdated Show resolved Hide resolved
@henryre
Copy link
Member

henryre commented Feb 14, 2021

The build issues should be resolved on trunk. Re-running for this PR: https://github.com/snorkel-team/snorkel/pull/1616/checks?check_run_id=1764471482

@antonis19
Copy link
Contributor Author

@henryre seems that all the tests are passing except for codecov/patch. What would we need to do to fix this?

Copy link
Member

@henryre henryre left a comment

Choose a reason for hiding this comment

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

@antonis19 the codecov issue is not clear to me, so happy to bypass it once the last comment is addressed!

snorkel/labeling/model/label_model.py Outdated Show resolved Hide resolved
Copy link
Member

@henryre henryre left a comment

Choose a reason for hiding this comment

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

🎉🎉🎉 Thanks so much for the contribution @antonis19 and your patience on the back-and-forth! Looking forward to getting this released!

@henryre henryre merged commit 1131d9b into snorkel-team:master Mar 1, 2021
akode pushed a commit to akode/snorkel that referenced this pull request Jun 10, 2022
## Description of proposed changes
Currently, `LabelModel` only accepts a `float` or an `int` for `prec_init`. These get converted into a 1D tensor of the same value. In this pull request, `prec_init` can be passed as  `np.ndarray` or as a Python list also. This way different labeling functions can get assigned different priors.

## Related issue(s)

Fixes snorkel-team#1484

## Test plan

## Checklist

Need help on these? Just ask!

* [ ✅ ] I have read the **CONTRIBUTING** document.
* [ ✅ ] I have updated the documentation accordingly.
* [ ✅ ] I have added tests to cover my changes.
* [ ✅ ] I have run `tox -e complex` and/or `tox -e spark` if appropriate.
* [ ✅ ] All new and existing tests passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error while providing prec_init as an array to LabelModel.fit()
2 participants