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

installation didn't show success and use of alarm example in mlnlearn shows parsing error #24

Open
AnujGandhi123 opened this issue Oct 28, 2018 · 12 comments

Comments

@AnujGandhi123
Copy link

snap
snap2

This is the result i got.
Please let me know how to correct the error.

@kaivalyar
Copy link
Collaborator

Hi,

Can you please provide more details of your installation process? Did you use pip install, or did you install from source? Also, please provide the complete output of installation process that didn't finally show success.

@AnujGandhi123
Copy link
Author

Thank you for getting back to me so quick.

I followed the instructions on the site pracmln.org.
My system is Ubuntu 16 and I've anaconda installed version3.6.3

I ran the installation in virtual environments in anaconda python 2.7.15 and python 3.5.5 and got the same results.

here are the steps i followed:
1.) sudo apt-get install python-tk
2.)git clone https://github.com/danielnyga/pracmln.git
3.)pip install pyparsing tabulate psutil==0.4.1 networkx (I did this only in my last few trials as i thought it was only for windows)
4.) cd pracmln/
5.)python setup.py install
6.)libpracmln-build

Also, i installed libboost but i can't find libpython-dev ( You can see it here:https://docs.anaconda.com/anaconda/packages/py2.7_linux-64/)

After this i didn't find any apps or get an output for mlnlearn in the output terminal.

screenshot from 2018-10-29 11-32-51
screenshot from 2018-10-29 11-32-38
screenshot from 2018-10-29 11-32-23
screenshot from 2018-10-29 11-32-00
screenshot from 2018-10-29 11-31-23
screenshot from 2018-10-29 11-31-05
screenshot from 2018-10-29 11-30-05

@kaivalyar
Copy link
Collaborator

Thank you.

It's a little difficult for me to parse the screenshots you have uploaded, but I assume you are able to go through steps 1-4 without any problems. If this is indeed the case, perhaps you could copy and paste the output from step 5: python setup.py install into pastebin or a gist and post the link here.

From a cursory glance at the images you've posted, it seems that you're using python2 on python3 code. The following snippet should illustrate this more simply than any descriptions I can provide:

kaivalya@kaivalyarawal ~ $ python2
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print 'hello'
hello
>>> print('hello')
hello
>>> print('hello', end='')
  File "<stdin>", line 1
    print('hello', end='')
                      ^
SyntaxError: invalid syntax
>>> 
kaivalya@kaivalyarawal ~ $ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello')
hello
>>> print('hello', end='')
hello>>> 

My guess is to use python3 setup.py install instead of python setup.py install.

Additionally, please note that step 6: libpracmln-build is required only if you wish to use pracmln from C++. That is, running steps 1-5 correctly is enough to be able to use the mlnlearn and mlnquery tools.

Hope this helps!

@AnujGandhi123
Copy link
Author

I ran python3 setup.py install and it worked without errors.
however, I can't start mlnlearn directly by just typing mlnlearn in the terminal.
I have to go to path "pracmln/python3/pracmln" and then run "python3 mlnlearn.py" manually

@AnujGandhi123
Copy link
Author

AnujGandhi123 commented Oct 29, 2018

mln file:

student = {S1, S2, S3, S4}
course = {C1, C2, C3, C4}
gradeValue = {A,B,C,D,None}
intval = {High,Low}
diffval = {High,Low}

//predicate
int(student, intval)
diff(course, diffval)
takes(student,course)
grade(student,course,gradeValue)
greater(gradeValue,gradeValue)
sameCourse(course,course)
diffStud(student,student)

//Formulae

Exist g grade(s,c,g).
grade(s,c,g) ^ (g=/= g') =>!grade(s,c,g').

// Student 'S' doesn't take course 'C' if and only if Grade of Student given Course is "None"

!takes(s,c) <=> grade(s,c,None).

/student 's1' takes course 'c1' and gets grades 'g1' AND student 's2' takes course 'c2' and gets grade 'g2' AND value of grade 'g1' is greater than 'g2' AND student 's1' and 's2' are different AND they take same course 'c1' AND student 's1' takes course 'c1' and student 's2' takes course 'c2' MPLIES intelligence of Student 's1' is High AND Intelligence of student 's2' is low/

0 (grade(s1,c1,g1)^grade(s2,c2,g2)^greater(g1,g2)^diffStud(s1,s2)^sameCourse(c1,c2)^takes(s1,c1)^takes(s2,c2)) =>( int(s1,High)^int(s2,Low))

0 (int(s3,High)^int(s4,Low)^!sameCourse(c3,c4)^grade(s3,c3,g3)^grade(s4,c4,g4)^diffStud(s3,s4)^takes(s3,c3)^takes(s4,c4)) => (diff(c3,High)^diff(c4,Low))

/* if intelligence of a student is high and intelligent of a different studetn is low and they don't take the same course-- the rest of the predicates same as above -- implies difficulty of course 1 is high and course 2 is low*/

0 (int(s,i) ^ diff(c, d)) => grade(s,c,g)

// intelligence and difficulty define grade of a person

@AnujGandhi123
Copy link
Author

database file:
greater(A,B)
greater(A,C)
greater(A,D)
greater(B,C)
greater(B,D)
greater(C,D)
!greater(B,A)
!greater(C,A)
!greater(D,A)
!greater(C,B)
!greater(D,B)
!greater(D,C)
!greater(A,None)
!greater(None,A)
!greater(B,None)
!greater(None,B)
!greater(C,None)
!greater(None,C)
!greater(D,None)
!greater(None,D)
sameCourse(C1,C1)
sameCourse(C2,C2)
sameCourse(C3,C3)
sameCourse(C4,C4)
!sameCourse(C1,C2)
!sameCourse(C1,C3)
!sameCourse(C1,C4)
!sameCourse(C2,C1)
!sameCourse(C2,C3)
!sameCourse(C2,C4)
!sameCourse(C3,C1)
!sameCourse(C3,C2)
!sameCourse(C3,C4)
!sameCourse(C4,C1)
!sameCourse(C4,C2)
!sameCourse(C4,C3)
diffStud(S1,S2)
diffStud(S1,S3)
diffStud(S1,S4)
diffStud(S2,S1)
diffStud(S2,S3)
diffStud(S2,S4)
diffStud(S3,S1)
diffStud(S3,S2)
diffStud(S3,S4)
diffStud(S4,S1)
diffStud(S4,S2)
diffStud(S4,S3)
!diffStud(S1,S1)
!diffStud(S2,S2)
!diffStud(S3,S3)
!diffStud(S4,S4)
grade(S1,C1,A)
grade(S2,C1,C)
grade(S1,C2,B)
grade(S2,C3,B)
grade(S3,C2,B)
grade(S4,C3,B)
grade(S1,C3,None)
grade(S2,C2,None)
grade(S1,C4,None)
grade(S2,C4,None)
takes(S1,C1)
takes(S2,C1)
takes(S1,C2)
takes(S2,C3)
takes(S3,C2)
takes(S4,C3)
//takes(S3,C4)
//takes(S4,C4)
!takes(S1,C3)
!takes(S1,C4)
!takes(S2,C4)
!takes(S2,C2)
diff(C1,High)
diff(C2,Low)
diff(C3,High)
int(S1,High)
int(S2,Low)

@AnujGandhi123
Copy link
Author

AnujGandhi123 commented Oct 29, 2018

I'm using ml learn to learn weights of the formula.
It works on alchemy but it shows an error on the pracmln toolbox.

screenshot from 2018-10-29 15-13-02
This is what i get as the output.

screenshot from 2018-10-29 15-13-24
This is what i get after commenting out "Exist g .." and the line after it.

screenshot from 2018-10-29 15-13-46
this is what i get after removing the brackets.

Your site says the package is compliant with Alchemy syntax. I went though your syntax page twice and changed some of the syntax but it shows me the same error.

@AnujGandhi123
Copy link
Author

gradeValue = {A,B,C,D,None}
intval = {High,Low}
diffval = {High,Low}

//predicate declarations
int(student,intval)
grade(student,course,gradeValue)
diffStud(student,student)
sameCourse(course,course)
diff(course,diffval)
takes(student,course)
greater(gradeValue,gradeValue)

// grade(s,c,g) ^ (g != g') => !grade(s,c,g').
!grade(a3,a4,a1) v !grade(a3,a4,a2) v a1 = a2.

// !takes(s,c) <=> grade(s,c,None).
!takes(a1,a2) v !grade(a1,a2,None).
takes(a1,a2) v grade(a1,a2,None).

// 3.99876 (grade(s1,c1,g1) ^ grade(s2,c2,g2) ^ greater(g1,g2) ^ diffStud(s1,s2) ^ sameCourse(c1,c2) ^ takes(s1,c1) ^ takes(s2,c2)) => (int(s1,High) ^ int(s2,Low))
0.000477248 int(a1,High) v !takes(a1,a2) v !takes(a3,a4) v !grade(a1,a2,a5) v !grade(a3,a4,a6) v !greater(a5,a6) v !sameCourse(a2,a4) v !diffStud(a1,a3)
3.99828 int(a1,Low) v !takes(a1,a2) v !takes(a3,a4) v !grade(a1,a2,a5) v !grade(a3,a4,a6) v !greater(a6,a5) v !sameCourse(a4,a2) v !diffStud(a3,a1)

// 0 (int(s3,High) ^ int(s4,Low) ^ !sameCourse(c3,c4) ^ grade(s3,c3,g3) ^ grade(s4,c4,g4) ^ diffStud(s3,s4) ^ takes(s3,c3) ^ takes(s4,c4)) => (diff(c3,High) ^ diff(c4,Low))
0 !int(a1,High) v !int(a2,Low) v diff(a3,High) v !takes(a1,a3) v !takes(a2,a4) v !grade(a1,a3,a5) v !grade(a2,a4,a6) v sameCourse(a3,a4) v !diffStud(a1,a2)
0 !int(a1,High) v !int(a2,Low) v diff(a3,Low) v !takes(a1,a4) v !takes(a2,a3) v !grade(a1,a4,a5) v !grade(a2,a3,a6) v sameCourse(a4,a3) v !diffStud(a1,a2)

// 0 (int(s,i) ^ diff(c,d)) => grade(s,c,g)
0 !int(a1,a2) v !diff(a3,a4) v grade(a1,a3,a5)

// 0 int(a1,a2)
0 int(a1,a2)

// 0 diff(a1,a2)
0 diff(a1,a2)

// 0 takes(a1,a2)
0 takes(a1,a2)

// -23.9922 grade(a1,a2,a3)
-23.9922 grade(a1,a2,a3)

// 0 greater(a1,a2)
0 greater(a1,a2)

// 0 sameCourse(a1,a2)
0 sameCourse(a1,a2)

// 0 diffStud(a1,a2)
0 diffStud(a1,a2)

// EXIST g grade(s,c,g).
EXIST g grade(s,c,g).

This is the output that i get from the Alchemy software for learning

@AnujGandhi123
Copy link
Author

We plan on learning of weights for data and using inference on our robots...we are looking for a ROS package for it to work on.

@kaivalyar
Copy link
Collaborator

Glad to know that your installation is successful. You are having to call python3 ~/ ... /pracmln/python3/pracmln/mlnlearn.py explicitly because the location pracmln/python3/pracmln has not been added to your pythonpath. I don't use anaconda myself, and am thus not sure of the procedure for automatically including this in your pythonpath for your particular case.

If you are only planning to call the pracmln API, and not make any changes to it, then perhaps an automatic pip install pracmln would be easier than manually cloning the repo from GitHub and running setup.py. However, if you wish to use the latest version of pracmln from GitHub, or wish to modify the code before use, then perhaps you can follow the additional steps mentioned here after manual installation. Note that the latest version of pracmln already has the symlink, so step 3 (ln -s _version python3/pracmln/_version) mentioned here has since become redundant. You only need to run the subsequent commands declaring and exporting the complete pythonpath.

@AnujGandhi123
Copy link
Author

AnujGandhi123 commented Oct 31, 2018

Thank You..
can you tell me why parsing through the mln ,that I've created in alchemy and used in pracmln, shows error?
what convention is incorrect.. is the mutually exclusive property used correctly?
why is it showing syntax errors as shown above?

@AnujGandhi123
Copy link
Author

lnlearn.py: l.1073: update_config

PRAC LEARNING TOOL

loaded 1 database(s).
Parameter: Value:


db 1 Databases
discr_preds 0
epreds
grammar PRACGrammar
ignore_unknown_preds 0
ignore_zero_weight_formulas 0
incremental 0
logic FirstOrderLogic
method DBPLL_CG
mln <pracmln.mln.base.MLN object at 0x7fea89eab0f0>
multicore 1
output_filename learnt.dbpll_cg.student-new-train-student-new-2.mln
params
pattern
prior_mean 0
prior_stdev 5
profile 0
qpreds
save 1
shuffle 0
use_initial_weights 0
use_prior 0
verbose 1
grounding...
Traceback (most recent call last):
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 27, in call
result = self.func(*args,**kwargs)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 47, in create_formula_groundings
checkmem()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 67, in checkmem
if float(psutil.virtual_memory().percent) > 75.:
AttributeError: module 'psutil' has no attribute 'virtual_memory'
Traceback (most recent call last):
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 27, in call
result = self.func(*args,**kwargs)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 47, in create_formula_groundings
checkmem()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 67, in checkmem
if float(psutil.virtual_memory().percent) > 75.:
AttributeError: module 'psutil' has no attribute 'virtual_memory'
Traceback (most recent call last):
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 27, in call
result = self.func(*args,**kwargs)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 47, in create_formula_groundings
checkmem()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 67, in checkmem
if float(psutil.virtual_memory().percent) > 75.:
AttributeError: module 'psutil' has no attribute 'virtual_memory'
Traceback (most recent call last):
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 27, in call
result = self.func(*args,**kwargs)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 47, in create_formula_groundings
checkmem()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 67, in checkmem
if float(psutil.virtual_memory().percent) > 75.:
AttributeError: module 'psutil' has no attribute 'virtual_memory'
2018-10-31 03:14:21 - ERROR - Error in child process. Terminating pool...
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/home/anuj/anaconda3/lib/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 34, in call
raise e
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 27, in call
result = self.func(*args,**kwargs)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 47, in create_formula_groundings
checkmem()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 67, in checkmem
if float(psutil.virtual_memory().percent) > 75.:
AttributeError: module 'psutil' has no attribute 'virtual_memory'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "mlnlearn.py", line 1165, in learn
result = learning.run()
File "mlnlearn.py", line 404, in run
mlnlearnt = mln.learn(dbs, self.method, **params)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/base.py", line 426, in learn
wt = learner.run(**params)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/learning/common.py", line 183, in run
self._prepare()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/learning/bpll.py", line 203, in _prepare
for _ in grounder.itergroundings(): pass
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/default.py", line 108, in itergroundings
gf = next(self.grounder)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 198, in _itergroundings
raise e
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 188, in _itergroundings
for gndresult in pool.imap(with_tracing(create_formula_groundings), self.formulas):
File "/home/anuj/anaconda3/lib/python3.6/multiprocessing/pool.py", line 735, in next
raise value
AttributeError: module 'psutil' has no attribute 'virtual_memory'
mlnlearn.py: l.1073: update_config

PRAC LEARNING TOOL

loaded 1 database(s).
Parameter: Value:


db 1 Databases
discr_preds 0
epreds
grammar StandardGrammar
ignore_unknown_preds 0
ignore_zero_weight_formulas 0
incremental 0
logic FirstOrderLogic
method DBPLL_CG
mln <pracmln.mln.base.MLN object at 0x7fea92901eb8>
multicore 1
output_filename learnt.dbpll_cg.student-new-train-student-new-2.mln
params
pattern
prior_mean 0
prior_stdev 5
profile 0
qpreds
save 1
shuffle 0
use_initial_weights 0
use_prior 0
verbose 1
grounding...
Traceback (most recent call last):
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 27, in call
result = self.func(*args,**kwargs)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 47, in create_formula_groundings
checkmem()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 67, in checkmem
if float(psutil.virtual_memory().percent) > 75.:
AttributeError: module 'psutil' has no attribute 'virtual_memory'
Traceback (most recent call last):
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 27, in call
result = self.func(*args,**kwargs)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 47, in create_formula_groundings
checkmem()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 67, in checkmem
if float(psutil.virtual_memory().percent) > 75.:
AttributeError: module 'psutil' has no attribute 'virtual_memory'
Traceback (most recent call last):
Traceback (most recent call last):
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 27, in call
result = self.func(*args,**kwargs)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 27, in call
result = self.func(*args,**kwargs)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 47, in create_formula_groundings
checkmem()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 47, in create_formula_groundings
checkmem()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 67, in checkmem
if float(psutil.virtual_memory().percent) > 75.:
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 67, in checkmem
if float(psutil.virtual_memory().percent) > 75.:
AttributeError: module 'psutil' has no attribute 'virtual_memory'
AttributeError: module 'psutil' has no attribute 'virtual_memory'
2018-10-31 03:14:40 - ERROR - Error in child process. Terminating pool...
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/home/anuj/anaconda3/lib/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 34, in call
raise e
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 27, in call
result = self.func(*args,**kwargs)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 47, in create_formula_groundings
checkmem()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/utils/multicore.py", line 67, in checkmem
if float(psutil.virtual_memory().percent) > 75.:
AttributeError: module 'psutil' has no attribute 'virtual_memory'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "mlnlearn.py", line 1165, in learn
result = learning.run()
File "mlnlearn.py", line 404, in run
mlnlearnt = mln.learn(dbs, self.method, **params)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/base.py", line 426, in learn
wt = learner.run(**params)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/learning/common.py", line 183, in run
self._prepare()
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/learning/bpll.py", line 203, in _prepare
for _ in grounder.itergroundings(): pass
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/default.py", line 108, in itergroundings
gf = next(self.grounder)
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 198, in _itergroundings
raise e
File "/home/anuj/anaconda3/lib/python3.6/site-packages/pracmln/mln/grounding/bpll.py", line 188, in _itergroundings
for gndresult in pool.imap(with_tracing(create_formula_groundings), self.formulas):
File "/home/anuj/anaconda3/lib/python3.6/multiprocessing/pool.py", line 735, in next
raise value
AttributeError: module 'psutil' has no attribute 'virtual_memory'

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

No branches or pull requests

2 participants