Adding probabilities, weighted edges and annotations #52
Replies: 5 comments
-
Hi @dyumanaditya, Please help me with the details for above mentioned points. |
Beta Was this translation helpful? Give feedback.
-
Hello @KaminiAggarwal,
Here are instructions on how to use annotation functions with PyReason. What are annotation functions?User defined Python functions that are called when all clauses in a rule have been satisfied to annotate the target of the rule. Annotation functions have access to the bounds of grounded atoms for each clause in the rule and use these bounds to make an annotation for the target of the rule. The Structure of an annotation functionOnly specifically structured annotation functions are allowed. The function has to be decorated with import numba
import numpy as np
@numba.njit
def ann_fn(annotations, weights):
# annotations contains the bounds of the atoms that were used to ground the rule. It is a nested list that contains a list for each clause
# You can access for example the first grounded atom's bound by doing: annotations[0][0].lower or annotations[0][0].upper
a, b = np.random.rand(2)
return a, b Adding the function in PyReason (using function example above)Use
This will set the bounds of |
Beta Was this translation helpful? Give feedback.
-
Thank you @dyumanaditya for providing the details. They are very useful. Also, regarding probability, Here's a simple use case below: trendy(x) <- cool_car(x) or cool_pet(x) What is the probability of a person being trendy? Given the probability of x owning a cool_pet is 0.05 and x owning a cool_car is 0.02. Thereafter, if we further specify a rule that if all people in a group are trendy, the group is popular. popular(x) -> GroupMember(x,y) and trendy(y) What is the probability of a group being popular? |
Beta Was this translation helpful? Give feedback.
-
@dyumanaditya Here is another example of how we want to use edge probabilities: Consider an unstable network with nodes A, B & C. |
Beta Was this translation helpful? Give feedback.
-
Hi @KaminiAggarwal in my opinion, probability is not the best way to go about it. While I understand where you are coming from, pyreason is built on reasoning about graphs and connections in graphs must either exist or not exist. However, what we do already support is open-world interval logic. So, every ground atom has an annotation in the range [0.0, 1.0]. This is not probability, but instead uncertainty. While on the surface, and in most simple cases - you may choose to model probability as uncertainty; it is worth exploring if in your domain this simplification holds. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm looking for details on below points for working on a use case involving probabilities.
Beta Was this translation helpful? Give feedback.
All reactions