Closed AnujGandhi123 closed 5 years ago
Update: Sunday 26th August
I managed to get some answer using Alchemy. I'm attaching the files here./home/anuj/alchemy-2/bin/student-new-2.mln /home/anuj/alchemy-2/bin/student-new-train.db /home/anuj/alchemy-2/bin/student-new-try.db
It would be relatively straightforward to translate the BLN into an MLN. There is an automated translation tool in ProbCog for this purpose (BLN2MLN). Unfortunately, it doesn't support one of the features of the network. Feel free to extend it and issue a pull request.
BTW, I don't see any attachment.
.mln file ...(this was made for alchemy)
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) grade(student,course,gradeValue) greater(gradeValue,gradeValue) sameCourse(course,course) diffStud(student,student) takes(student,course)
//Formulae
!takes(s,c) <=> grade(s,c,None). // Student 's' takes course 'C' if and only if Grade of Stdent given C is None
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)
/ Student 1 takes course C1 and gets grades G1 AND Student 2 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 C AND student 1 takes course 1 AND student 2 takes course 2 IMPLIES intelligence of Student S1 is High AND Intelligence of student 2 is low /
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 student is low and they don't take the samne course-- the rest of the predicates same as above -- IMPLIES difficulty of course 1 is high AND course 2 is low /
int(s,i) ^ diff(c, d) => grade(s,c,g)
// intelligence and difficulty define grade of a person
database to learn weights... again in Alchemy.
!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) 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(S2,C2) diff(C1,High) diff(C2,Low) diff(C3,High) int(S1,High) int(S2,Low)
database for inference....
takes(S3,C4) takes(S4,C4)
the answers that i get after inference..
Trial 14: using student-new-2.mln and in the output file only providing domain of gradevalue, IntValue and diffValue. grade(S3,C4,A) 0.0130487 grade(S3,C4,B) 0.0160484 grade(S3,C4,C) 0.0140486 grade(S3,C4,D) 0.0010499 grade(S3,C4,None) 4.9995e-05 grade(S4,C4,A) 0.0070493 grade(S4,C4,B) 0.0050495 grade(S4,C4,C) 0.0040496 grade(S4,C4,D) 0.0060494 grade(S4,C4,None) 4.9995e-05 Conclusion: results show that probability of S3 doing well is higher than S4. Also, value for grade(S4,C4,None) given takes(S4,C4) and Takes(S3,C4) is zero. Remark: 1.) Result obtained but can result be made better?
Trial 15: using generative weight learning and providing non-evidence predicates as grade,int,diff. grade(S3,C4,A) 0.0010499
grade(S3,C4,B) 4.9995e-05 grade(S3,C4,C) 4.9995e-05 grade(S3,C4,D) 4.9995e-05 grade(S3,C4,None) 4.9995e-05 grade(S4,C4,A) 4.9995e-05 grade(S4,C4,B) 0.0030497 grade(S4,C4,C) 4.9995e-05 grade(S4,C4,D) 0.0010499 grade(S4,C4,None) 4.9995e-05
both the inference answers seem to be equally right...however i can't be sure if my First Order Logic is correct..!
Also, what do you mean by "It doesn't support one of the features of the network in BLN2MLN conversion"?
Thank you for getting back to me !!!
This is the problem we're trying to solve..
The model you have pasted is clearly not a translation of the BLN model, and the inference results do not look "equally right" to me at all; both of them are obviously "wrong" to me, as you have not even modelled the fundamental functional property of the grade relation: the grades for any student-course pair should be mutually exclusive and exhaustive. Are you sure you fully understand the concepts of MLNs and BLNs? If you do, I could assist you in extendending BLN2MLN in order to generate a proper conversion. Otherwise, it's probably beyond the scope of this project. Also, if you are interested in inducing a model's parameters from data, you could make use of the generator script in the grades-ext directory (or a modification thereof, which is adapted to your needs).
I'm currently reading about both & wanted to know how the software works and what are the limitations of it. I would love to extend your work but my knowledge in coding is quite limited being from a purely mechanical background. I've moved on to robotics and have been working in the field for a year now but mostly on ROS. We wanted to know how starAI works and how we can use it in our current robotic projects in our college.
I started reading about BLN and MLN about 2 months ago and had to read a lot starting from Artificial Intelligence to probability to Algorithms to understand the subject.
Now coming back to the topic, thank you for the input I understand I have to model mutually exclusive and exhaustive property of predicate grade. In Alchemy ,however, we do this using '!' symbol next to variable g. But doing that shows error during compilation. So, I started with Exist g grade(s1,c1,g1). grade(s,c,g) ^ g!= g' =>!grade(s,c,g'). But even that gave me a compilation error. I'll try it out again tomorrow morning. Let me know if I'm incorrect in my assumption in use of '!' in Alchemy. I've been trying fill the gaps in my knowledge on the subject using this example. It's from the book "Statistical Relational Artificial Intelligence. Logic, Probability and Computation" by Luc De Raedt, Kristian Kersting, Sriraam Natarajan, David Poole.
I couldn't find a dedicated forum on the subject. And your package is much more versatile with ROS package available and we can directly start using it in our work. However, there is not much documentation on how it can be used in robotics save a very few examples for beginners.
After I have decent knowledge on the subject and more experience with coding, I'd love to help you out extending the algorithm.
Thank You for your input and your time..! I appreciate it.
I cannot provide support for Alchemy, but if you use ProbCog to model mutual exclusiveness and exhaustiveness in an MLN, using the ! operator in a predicate declaration will work without any problems. However, this is just one problem with your model (albeit a most obvious one).
I guess the main question at this point is: What are you actually trying to achieve and why do you need to achieve it with an MLN? Since the BLN model is likely to be more usable in practice, I suggest that you look into this further. Also, if you're trying to find applications in a robotics context, why are you working with a grades model, which presumably has no relevance to your field of work?
I want to code the same scenario of student, grade and course in mln format...but it looks like both have different formats...in the way you write your predicates..is that so? Can someone help me get code in mln i.e in First order logic?