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

Simple changes to handle missing values in BayesianModel predict methods #1119

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

robbymeals
Copy link

There may be a better/faster way to do this, but supporting missing variables easily in these predict methods will definitely make my own life easier.

Fixes #1118 . (if there is no issue for this, please create one)

Changes

  • Checks if input state name is either None or nan before converting to state index, returns original value if it is instead of failing from KeyError
  • Drops NA from series in map_query calls over iterrows

Thank you!

@codecov
Copy link

codecov bot commented Jun 10, 2019

Codecov Report

Merging #1119 into dev will decrease coverage by 0.00%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1119      +/-   ##
==========================================
- Coverage   92.93%   92.93%   -0.01%     
==========================================
  Files         130      130              
  Lines       12632    12634       +2     
==========================================
+ Hits        11740    11741       +1     
- Misses        892      893       +1     
Impacted Files Coverage Δ
pgmpy/models/BayesianModel.py 88.27% <ø> (ø)
pgmpy/utils/state_name.py 77.14% <66.66%> (-1.65%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b2ea305...f48c543. Read the comment docs.

@ankurankan
Copy link
Member

@robbymeals Thanks for the PR. I don't know much about different ways of dealing with missing values in BN and will have to do some literature reading for that.

For your changes could you add a warning message before dropping any rows in the data so that the user is aware of it? Also, could you please add some tests for the changes?

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.

Handle missing data in BayesianModel predict methods
2 participants