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

BayesianNetwork.predict throws error when using pytorch backend #1729

Open
ankurankan opened this issue Feb 19, 2024 · 0 comments
Open

BayesianNetwork.predict throws error when using pytorch backend #1729

ankurankan opened this issue Feb 19, 2024 · 0 comments
Labels

Comments

@ankurankan
Copy link
Member

ankurankan commented Feb 19, 2024

In [8]: model = get_example_model('cancer')                                             [285/285]
In [8]: model                                   
Out[8]: <pgmpy.models.BayesianNetwork.BayesianNetwork at 0x7efffd538ac0>                                                                         
In [9]: model.nodes()                                                                            
Out[9]: NodeView(('Pollution', 'Smoker', 'Cancer', 'Xray', 'Dyspnoea'))                          
                                                                                                 
In [10]: df = model.simulate(100)                                                                
                                                                                                
WARNING:pgmpy:Probability values don't exactly sum to 1. Differ by: 2.2351741790771484e-08. Adjust
ing values.                                                                                      Generating for node: Dyspnoea: 100%|██████████████████████████████| 5/5 [00:00<00:00, 695.46it/s]
/home/ankur/pgmpy/pgmpy/sampling/base.py:598: FutureWarning: Passing a DataFrame to DataFrame.fro
m_records is deprecated. Use set_index and/or drop to modify the DataFrame instead.              
  df = pd.DataFrame.from_records(samples)                                                        
                                                                                                 
In [12]: df_small = df.drop('Xray', axis=1)                                                      
                                                                                                 
In [13]: model.predict(df_small)   

Error

ValueError: einstein sum subscripts string contains too many subscripts for operand 0     
@ankurankan ankurankan added the Bug label Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant