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

Variable naming inconsistency? #961

Closed
theUltraMarine19 opened this issue Dec 20, 2017 · 7 comments · Fixed by #1330
Closed

Variable naming inconsistency? #961

theUltraMarine19 opened this issue Dec 20, 2017 · 7 comments · Fixed by #1330

Comments

@theUltraMarine19
Copy link
Contributor

Subject of the issue

In line 54, 55 of pgmpy/pgmpy/models/LinearGaussianBayesianNetwork.py, cpd.variables has been checked for, whereas, line 66 of pgmpy/pgmpy/factors/continuous/LinearGaussianCPD.py has self.variable specified and not variables. Hence, I think that this error is being raised. Highly obliged if you look into it.

Your environment

  • pgmpy version : 0.1.6
  • Python version : 3.4
  • Operating System : Ubuntu 14.04

Steps to reproduce

from pgmpy.models import *
model = LinearGaussianBayesianNetwork([('hist_dist', 'dist_relevance'),('curr_dist', 'dist_relevance'),('monthly_exp','offer_interest'),('cat_merchant_affinity','offer_interest'),
('offer_interest','offer_hit_effect'),('dist_relevance','offer_hit_effect')])

model.add_nodes_from(['hist_dist', 'curr_dist', 'dist_relevance','monthly_exp','cat_merchant_affinity','offer_interest','offer_hit_effect'])

from pgmpy.factors.continuous import LinearGaussianCPD

hist_dist_cpd = LinearGaussianCPD('hist_dist', [200], 20)
curr_dist_cpd = LinearGaussianCPD('curr_dist', [400], 50)
dist_rel_cpd = LinearGaussianCPD('dist_relevance', [0, 0.5, 0.5], 0.1, ['hist_dist', 'curr_dist'])

monthly_exp_cpd = LinearGaussianCPD('monthly_exp', [45000], 5000)
cat_merchant_cpd = LinearGaussianCPD('cat_merchant_affinity', [0.6], 0.2)
offer_interest_cpd = LinearGaussianCPD('offer_interest', [0, 0.7, 0.3], 0.1, ['monthly_exp', 'cat_merchant_affinity'])

offer_hit_effect_cpd = LinearGaussianCPD('offer_hit_effect', [0.1, 0.3, 0.6], 0.2, ['dist_relevance', 'offer_interest'])
model.add_cpds(hist_dist_cpd, curr_dist_cpd, dist_rel_cpd, monthly_exp_cpd, cat_merchant_cpd, offer_interest_cpd, offer_hit_effect_cpd)

Expected behaviour

No error

Actual behaviour

File "linearGaussian.py", line 25, in
model.add_cpds(hist_dist_cpd, curr_dist_cpd, dist_rel_cpd, monthly_exp_cpd, cat_merchant_cpd, offer_interest_cpd, offer_hit_effect_cpd)
File "/usr/local/lib/python3.4/dist-packages/pgmpy-0.1.6-py3.4.egg/pgmpy/models/LinearGaussianBayesianNetwork.py", line 54, in add_cpds
if set(cpd.variables) - set(cpd.variables).intersection(
AttributeError: 'LinearGaussianCPD' object has no attribute 'variables'

@theUltraMarine19
Copy link
Contributor Author

Error corrected : On line 78, 79 of LinearGaussianCPD.py, please put self.variables instead of variables.
All other things remaining the same.
If you grant permission, I can commit and push.

@ankurankan
Copy link
Member

@Arijit-hydrated Thanks for reporting this. Sure, if you would like to fix this, please create a pull request.

@JZQ-Coder
Copy link

I meet the same bug, so this bug has not been fixed in the current version(0.1.11) ?

@ankurankan
Copy link
Member

@JZQ-Coder No, it's not fixed it.

@theUltraMarine19
Copy link
Contributor Author

@JZQ-Coder The fix is simple and code changes are in this PR #962. I found it and sent out a PR to fix it 3 years ago

@JZQ-Coder
Copy link

JZQ-Coder commented Sep 29, 2020 via email

@ankurankan
Copy link
Member

@JZQ-Coder No, continuous variables are not completely supported. Continuous variables/ LinearGaussianCPDs are not completely integrated with all parts of the package, so you will run into errors.

theUltraMarine19 added a commit to theUltraMarine19/pgmpy that referenced this issue Sep 30, 2020
This was causing a compilation error when declaring LinearGaussianCPDs and adding it to a LinearGaussianBayesianNetwork model
theUltraMarine19 added a commit to theUltraMarine19/pgmpy that referenced this issue Sep 30, 2020
This was causing a compilation error when declaring LinearGaussianCPDs and adding it to a LinearGaussianBayesianNetwork model
theUltraMarine19 added a commit to theUltraMarine19/pgmpy that referenced this issue Sep 30, 2020
This was causing a compilation error when declaring LinearGaussianCPDs and adding it to a LinearGaussianBayesianNetwork model
ankurankan pushed a commit that referenced this issue Oct 8, 2020
This was causing a compilation error when declaring LinearGaussianCPDs and adding it to a LinearGaussianBayesianNetwork model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants