## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Jan 19 20:56
fborcic commented #889
• Jan 16 13:24
ankurankan commented #782
• Jan 16 12:30

ankurankan on dev

Better integration of state nam… (compare)

• Jan 16 12:30
ankurankan closed #1217
• Jan 16 12:25
codecov[bot] commented #1217
• Jan 16 12:23
codecov[bot] commented #1217
• Jan 16 12:23
codecov[bot] commented #1217
• Jan 16 12:23
codecov[bot] commented #1217
• Jan 16 12:15
Travis ankurankan/pgmpy (feature/state_names) fixed (1228)
• Jan 16 12:13
ankurankan edited #1215
• Jan 16 12:12
Travis ankurankan/pgmpy (feature/state_names) canceled (1229)
• Jan 16 12:11
ankurankan synchronize #1217
• Jan 16 12:07
ankurankan edited #1217
• Jan 16 12:04
ankurankan synchronize #1217
• Jan 16 11:51
ankurankan opened #1221
• Jan 16 09:43
Travis pgmpy/pgmpy#1217 broken (2642)
• Jan 16 09:43
Travis ankurankan/pgmpy@9111728 (feature/travis_os) failed (1225)
• Jan 16 09:35
Travis ankurankan/pgmpy (feature/state_names) canceled (1226)
• Jan 16 09:35
ankurankan synchronize #1217
• Jan 16 09:34
Danish A. Alvi
Here is the code

hc = HillClimbSearch(train_data, scoring_method=BicScore(train_data)); # Initialise Hill Climbing Estimator
expert = BayesianModel();
('STEO.PAPR_NONOPEC.M', 'WTISPLC'),
('STEO.PAPR_OPEC.M', 'WTISPLC'),
('STEO.PATC_OECD.M', 'WTISPLC'),
('STEO.PATC_NON_OECD.M', 'WTISPLC'),
('STEO.RGDPQ_OECD.M', 'STEO.PATC_OECD.M'),
('STEO.RGDPQ_NONOECD.M', 'STEO.PATC_NON_OECD.M'),
('STEO.FOREX_WORLD.M', 'WTISPLC')
]);

model = hc.estimate(start=expert, max_indegree=6, tabu_length=1000); # Performs local hill climb search

here is the data
Danish A. Alvi
The problem is that the initial 'expert' structure i define does not show up after the Hill Climber
abbasi72
@abbasi72
Hi, in make the bayesian network , I change my string name to numerical ...and in train data ,I have 12 type but in test data, every where find the number of >9 , the run is stoping and show this error :index 11 is out of bounds for axis 0 with size 10
Am I delete the datas >9?????? or are there any solution ?????
abbasi72
@abbasi72
Utkarsh
@khalibartan
@abbasi72 I'm able to understand what are you trying say.
abbasi72
@abbasi72
Location Place Activity
9 3 8
12 3 8
12 2 8
12 2 8
12 3 8
9 3 8
12 3 8
12 0 9
12 0 9
1 1 8
12 3 8
9 3 9
12 3 1
1 1 1
8 1 3
12 0 3
10 0 3
12 0 3
8 1 1
12 3 4
12 3 4
12 2 4
6 2 4
11 2 4
12 2 4
12 0 8
12 0 8
12 3 8
9 3 8
12 3 8
12 0 9
12 0 9
1 1 9
0 1 2
12 3 9
12 3 9
12 2 9
12 2 9
1 1 9
8 1 1
1 1 9
this is a sample of my data set . I have 0...9 item in my class feature ... but in result only see 2 item that predict...
9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 9, 0, 0, 8, 8, 9, 8, 8, 8, 8, 8, 9, 8, 9, 8, 8, 8, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 9, 9, 9, 8, 8, 8, 9, 9, 8, 8, 8, 8, 8, 8, 8, 9, 8, 9, 8, 8, 9, 9, 8, 0, 0, 8, 9, 9, 9, 8, 8, 8, 8, 9, 9, 8, 8, 8, 9,
this is a sample of resultlist that predict ....
how can I use from multi class ???
Utkarsh
@khalibartan
@abbasi72 Can you share your code and dataset?
abbasi72
@abbasi72
this is my code

array=['Activity']
trainstart=time()
bic=BicScore(train)

hc=HillClimbSearch(train, scoring_method=bic)
best_model=hc.estimate()
edges=best_model.edges()
model=BayesianModel(edges)
model.fit(train,estimator=BayesianEstimator, prior_type="BDeu")

trainend=time()-trainstart

print "nodes", model.nodes()
print "edges", model.edges()

flag=0
if(set(model.nodes())-set(array) ==set(model.nodes())):
flag=1
elif(set(model.nodes())-set(array) == set(test.columns)):
teststart=time()
print "before"
draw(model.edges(),name,"bic",folder)
result=model.predict(test).values.ravel()
print result
testend=time()-teststart

pred=list(result)
print pred

else:
indicator=list(set(test.columns)-set(model.nodes()))
print indicator
testchange=test.copy()
for f in range(len(indicator)):
print f
del testchange[indicator[f]]
print testchange
teststart=time()
result=model.predict(testchange).values.ravel()
testend=time()-teststart
pred=list(result)

model_data = XMLBIFWriter(model)

if(flag==0):

fscore,accuracy,precision,recall=calscore(resultlist,pred)

draw(model.edges(),name,"bic",folder)

else:
fscore=accuracy=precision=recall=trainend=testend=0
print "fscore :",fscore
print "accuracy :",accuracy
print "precision :",precision
print "recall :",recall
plt.scatter(pred , resultlist)
return fscore,accuracy,precision,recall,trainend,testend

secondtestindicexls1=pd.ExcelFile("D:\OrdonezB_Sensors.xls")
secondtestindicedf1=secondtestindicexls1.parse("OSB")
secondtestindicexls2=pd.ExcelFile("D:\OrdonezA_Sensors.xls")
secondtestindicedf2=secondtestindicexls2.parse("OSA")
secondtestindicexls3=pd.ExcelFile("D:\label.xlsx")
secondtestindicedf3=secondtestindicexls3.parse("Sheet1")
bic(secondtestindicedf1,secondtestindicedf2,"res11","D:\result of run python\",secondtestindicedf3,"D:\result of run python\")

abbasi72
@abbasi72
Danish A. Alvi
@ankurankan Take a look at my project! Thank you for your help all the way with my journey! pgmpy is a wonderful tool with an unlimited potential, and there is a lot more that can be done with it.
odirar
@odirar
@ankurankan hey everyone, newbie to pgmpy, seem to have hit an issue that im not quite sure how to fix. In trying to implement the example on pg 190 of chapter 5, i seem to be getting empty cpds (and model) for some reason. ive provided some screenshots below to help clarify the issue im having. i think this is due to the versions of networkx, scipy, numpy and pandas that im using but im not sure. can you guys please help?
Utkarsh
@khalibartan
@odirar I see, you haven't added any edges in the model. For parameter estimation you must first specify the structure of model.
odirar
@odirar
@khalibartan ahh see ok thanks. How would i go about doing both structure and parameter learning from a dataset? Would i do it as described in /pgmpy/pgmpy_notebook/notebooks/9. Learning Bayesian Networks from Data.ipynb in the repo? or is there perhaps an alternate way of doing this? thanks again. (https://github.com/pgmpy/pgmpy_notebook/blob/master/notebooks/9.%20Learning%20Bayesian%20Networks%20from%20Data.ipynb)
Utkarsh
@khalibartan
@odirar Yes you can you use that. In case if it raises some import error, checkout docs. We have changed directory structure and notebooks example might not have been updated to reflect those.
odirar
@odirar
@khalibartan ahh ok will do, thank you for the insight, much appreciated :)
odirar
@odirar
@khalibartan hey, sorry to bother you again, but i just wanted to ask, is pgmpy (0.1.6) able to compute joint distributions over multiple variable using variable elimination? or is there any other way of doing this atm? (pgmpy/pgmpy#945)
Utkarsh
@khalibartan
@odirar No currently it doesn't.
z2862658714
@z2862658714

Hello there, I'm trying to work out the ProbModelXML file format by generating a file from a working model I created using the method said on the notebook tutorial (https://github.com/pgmpy/pgmpy_notebook/blob/master/notebooks/8.%20Reading%20and%20Writing%20from%20pgmpy%20file%20formats.ipynb)

model_data = get_probmodel_data(valve_model);
writer = ProbModelXMLWriter(model_data=model_data);
print(writer);

and it give me this error

Traceback (most recent call last):
File "/Users/-/Desktop/Valve.py", line 49, in <module>
model_data = get_probmodel_data(valve_model);
File "/Users/-/anaconda3/lib/python3.5/site-packages/pgmpy/readwrite/ProbModelXML.py", line 266, in get_probmodel_data
model_data['probnet']['edges'][str(edge)] = model.edge[edge[0]][edge[1]]
AttributeError: 'BayesianModel' object has no attribute 'edge'

I tried to fix it by modify line 266 in ProbModelXML.py to

model_data['probnet']['edges'][str(edge)] = model.edges[edge[0]][edge[1]]

and now I'm receiving this error:

Traceback (most recent call last):
File "/Users/-/Desktop/Valve.py", line 49, in <module>
model_data = get_probmodel_data(valve_model);
File "/Users/-/anaconda3/lib/python3.5/site-packages/pgmpy/readwrite/ProbModelXML.py", line 266, in get_probmodel_data
model_data['probnet']['edges'][str(edge)] = model.edges[edge[0]][edge[1]]
File "/Users/-/anaconda3/lib/python3.5/site-packages/networkx/classes/reportviews.py", line 930, in getitem
KeyError: 'n'

It seems like there's an error associated with the indexing (model.edges[edge[0]][edge[1]]), but I'm not sure how to fix it. Would appreciate if anyone could help.

Mariangelly Díaz
hi all, new to pgmpy. Is there a way I can produce a flow diagram of my variables within the package?
Matthias Lung
@mmmlung
Hi. I am starting to study PGM (1 week into Courseras course by Daphne Koller). I am playing with my first toy model using PGMPY : ) Is it possible to modify state names ? I came around PGMPY util.state_name but did not quite understand how it works. I would be grateful for a hint ; )
Jonathan Mugan
@jmugan
Are there any examples of people using pgmpy for expectation maximization (EM) for Bayesian networks with hidden variables?
ranxiao89
@ranxiao89
Hi. How can I access the values from a table from a VariableElimination query result?
sphinx-jiang
@sphinx-jiang
Hi guys, do any of you met my issue: import pgmpy fail in jupyter notebook, but could run it in python file?
For details, I have logged issue:pgmpy/pgmpy#1024
@khalibartan jupyter notebook is supported, right?
hcl734
@hcl734

@jmugan

Are there any examples of people using pgmpy for expectation maximization (EM) for Bayesian networks with hidden variables?

Have you found anything on this?
I would also be interested.

Rashmeet Nayyar
@Rashmeet09
Hi guys, is there support for gaussian as well discrete nodes while constructing bayesian networks now (hybrid model)?
Rashmeet Nayyar
@Rashmeet09
Or is there a way to specify evidence when using the ContinuousFactor (for creating a continuous random variable node)?
James Matthew Miraflor
@miraflor
Hello pgmpy community! I'm looking forward to contribute modules soon.
Chester
@llsjdkn
hi everynoe, there are some bugs in models-DynamicBayesianNetork.py-get_cpds(). Has it been fixed? Thanks for any help.
karnatapu
@karnatapu
hello
i see lot of fixes made to the orginal code, do anyone know how to pull latest code which has the bug fixes. Git clone gives non-fix solution. any clue
Ankur Ankan
@ankurankan
@karnatapu You can use pip: pip install pgmpy --upgrade. It should update to the latest version.
kbe206
@kbe206
df = pd.DataFrame(data)
est = HillClimbSearch(df, scoring_method=BicScore(df))
best_model = est.estimate()
edges = best_model.edges()
unsupported operand type(s) for +: 'OutEdgeView' and 'list'
Some people have this problem？
Ankur Ankan
@ankurankan
@kbe206 Try downgrading networkx to 1.11