-
Notifications
You must be signed in to change notification settings - Fork 19
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
Ignoring equivalent rules when mining symmetric relations #40
Comments
Hi Antonio, I fully agree with your observation and while this seems to require quite some hacks, I would not mind to have it as a mining assistant. I only have one remark: Does your analysis assume that the inverse relationships are fully materialized? Best, |
Hi,
I guess that most part of the hack comes from extending parts which are a little bit hard to currently extend in AMIE.
I'm not sure if I understand what you meant. But yes, at least in my case/currently, I provide AMIE with both Post-processing is indeed interesting, and would be done using the For the new bias, I'd love to be able to create a "ReflexiveInvariantRule", similar to InjectiveRule (see #33 (comment)). As this is not currently supported, I will indeed implement a custom MiningAssistant. In order to enable the special treatment to reflexive-relations, I see a few ways:
I think that infering the inverse triple would also require checking for Option
On the other hand, If you think that one of these (or another) approaches would be more close to get into upstream AMIE, I would gladly opt to implement it that way. Regards, |
Hi Antonio, I vote for implementing option 1.i as it is the simplest (the user can always run AMIE with 2 atoms to identify those patterns and then use that info to make the mining of longer rules faster), although from a user perspective 1.b is more useful. This functionality would have been useful for these cases (a), (b) |
I've been wrongly (and consistently) using the term
reflexive
, but I am actually referring to the termsymmetric
. I updated the issue's title for clarity, but the whole discussion below regardingreflexive
relations is actually aboutsymmetric
relations.Contextualization
My KB has some reflexive-relations, i.e., if
r
is reflexive,r(x, y) ∈ KB <=> r(y, x) ∈ KB
.Mining rules with such relations yields many equivalent rules. In this issue, I will report my approach to prune/filter these duplicated rules. I would be happy if you could provide any comments that you think might be helpful.
Equivalent rules
Two cases yield equivalent rules. The first case is swapped reflexive relations' arguments.
Consider the following rules:
functional_relation(a, X), reflexive_relation1(a, b) => reflexive_relation2(a, b)
functional_relation(a, X), reflexive_relation1(a, b) => reflexive_relation2(**b**, **a**)
functional_relation(a, X), reflexive_relation1(**b**, **a**) => reflexive_relation2(a, b)
Note that
Rules 2.
and3.
are equivalent to1.
, since they only differ by the parameter's order of a reflexive relation.The second equivalent case is a little bit harder to spot. Consider the following rule:
functional_relation(**b**, X), reflexive_relation1(a, b) => reflexive_relation2(a, b)
This rule is also equivalent to
1.
See the details below for proof.Proof
Given 4., we can:
functional_relation(b, X), reflexive_relation1(b, a) => reflexive_relation2(b, a)
;?a
for?b
, and?b
for?a
:functional_relation(a, X), reflexive_relation1(a, b) => reflexive_relation2(a, b)
.Of course, these two equivalent cases can occur simultaneously.
My approach
Given a set of known reflexive relations, my approach to detect (and prune) these equivalent rules is two-fold:
Add a new bias to the Dangling and Closing Operators. This new bias imposes that if
r
is reflexive, its subject variable must be smaller than its object variable.Modify Rule.equals in order to consider all posible permutations of all reflexive relations within a rule. I.e., for rules
R1
andR2
, instead of only checkingQueryEquivalence(R1, R2)
, checkQueryEquivalence
betweenR1
and each ofget_all_reflexive_permutations(R2)
.Rule.equals example
For example, let's do
R1=Rule 1.
andR2=Rule 4.
We have thatget_all_reflexive_permutations(R2)
yields 4 permutations:functional_relation(b, X), reflexive_relation1(a, b) => reflexive_relation2(a, b)
functional_relation(b, X), reflexive_relation1(a, b) => reflexive_relation2(b, a)
functional_relation(b, X), reflexive_relation1(b, a) => reflexive_relation2(a, b)
functional_relation(b, X), reflexive_relation1(b, a) => reflexive_relation2(b, a)
Each of them is compared with
QueryEquivalence
withR1
. If any of them is equivalent toR1
, thenR2
is equivalent toR1
.Note that the new bias reduces the number of generated rules, while the new
Rule.equals
does not allow reflexive-equivalent rules inAMIEQueue
.Expectative
My expectative was that all these equivalent rules yielded the same metrics. This is true for support and body size, but not for PCA body size.
Indeed, I noticed that the two following mined rules presented different PCA confidence:
functional_relation(a, X), reflexive_relation1(a, b) => reflexive_relation2(a, b)
functional_relation(b, X), reflexive_relation1(a, b) => reflexive_relation2(a, b)
More specifically, the second rule had a smaller PCA body size, and therefore a greater PCA confidence.
Reality
When calculating the PCA body size,
Rule 1.
yields the PCA body size query:functional_relation(a, X), reflexive_relation1(a, b), reflexive_relation2(a, x9)
Rule 2.
yields the PCA body size query:functional_relation(b, X), reflexive_relation1(a, b), reflexive_relation2(a, x9)
At this point, the two queries are not equaled anymore.
For example, let's instantiate the most restrictive atom in both queries:
a
:functional_relation(CONST, X), reflexive_relation1(CONST, b), reflexive_relation2(CONST, x9)
b
:functional_relation(CONST, X), reflexive_relation1(a, CONST), reflexive_relation2(a, x9)
i.e., in the first case,
CONST
must have areflexive_relation2
, while in the second case, it isa
. Consequently, this yields different body sizes.My workaround
As far as I thought, the new bias I introduced can still be used. The issue occurs when eliminating rules based on my new
Rule.equals
, since two rules might be equal, but yield different PCA Confidence.My idea then is to maintain the new bias and add a new output check (similar to skyline). It works as follows:
r(s, o)
andr
is reflexive, thenKB.map(s) > KB.map(o)
;Rule.equals
, but also implement aRule.reflexive_equals
;output set
, check if there is already an equal rule usingRule.reflexive_equals
;Since the problem occurs only if the head relation is reflexive, a further optimization step is:
Is this too much of a hack? Or does it make sense within the reflexive "issue" I'm trying to fix?
The only problem I saw is that modifying the
output set
requires-oute
to be specified.Any idea is welcomed.
Best,
Antonio.
The text was updated successfully, but these errors were encountered: