Closed Danielmulerr closed 3 years ago
Can you plot the DAG?
bn.plot(DAG)
Is _data_selected numerical without missing values?
I created a update, maybe it solved your issue as well. The new version of networkx gave some issues. Install the latest bnlearn version as following:
pip install -U bnlearn
import bnlearn as bn
print(bn.__version__)
# Should be >= 0.3.8
If this did not solve your issues, can you send me a small part of your data? That can help to replicate your issue.
i will check the new version. does the parameter learning work for continuous attributes/featurs ? if not how can i deal with it ?
There is no implementation yet for continuous values. Its on my long list of todos ;)
thank you for your reply. can you suggest me any other tool that can do it, or if I can apply data discretization on the values on this library?
You can think if descritizing your data. Maybe there is a “natural” point that you can use? As an example, if you have temperature you can decide to make 2 or more categories such as Cold and warm. Otherwise you can try to look into the pgmpy, maybe here: https://pgmpy.org/factors.html#continuous
here i have created a list of edges that are already learned by the structure learning edges = [('no_comment', 'O'), ('no_priority_change', 'priority'), ('O', 'no_fixversion_change'), ('O', 'perofdelay'), ('O', 'no_fixversion'), ('O', 'repetition')] DAG = bn.make_DAG(edges)
use the features that are included in the DAG to select the data
_data_selected = data[['no_comment', 'no_priority_change', 'priority', 'no_fixversion_change', 'perofdelay', 'no_fixversion', 'repetition','O']]
use the dataframe with the selected features for parameter learning
model_p = bn.parameter_learning.fit(DAG, _data_selected) the error is as followa, Traceback (most recent call last): File "E:/dn/Issue/bayesian learning/bn.py", line 167, in
_parameter_learning(dataset[1])
File "E:/dn/Issue/bayesian learning/bn.py", line 153, in _parameter_learning
_model_p = bn.parameter_learning.fit(DAG, _data_selected)
File "C:\ProgramData\Anaconda3\envs\tensor2\lib\site-packages\bnlearn\parameter_learning.py", line 72, in fit
adjmat = model['adjmat']
File "C:\ProgramData\Anaconda3\envs\tensor2\lib\site-packages\networkx\classes\graph.py", line 475, in getitem
return self.adj[n]
File "C:\ProgramData\Anaconda3\envs\tensor2\lib\site-packages\networkx\classes\coreviews.py", line 81, in getitem
return AtlasView(self._atlas[name])
KeyError: 'adjmat'
I believe the problem is it is unable to get the adjmat values. please is there is any way around this let me know ... I am in hurry.