get_relation_pattern_types_df
- get_relation_pattern_types_df(dataset: Dataset, *, min_support: int = 0, min_confidence: float = 0.95, drop_confidence: bool = False, parts: Collection[str] | None = None, force: bool = False, add_labels: bool = True) DataFrame[source]
Categorize relations based on patterns from RotatE [sun2019].
The relation classifications are based upon checking whether the corresponding rules hold with sufficient support and confidence. By default, we do not require a minimum support, however, a relatively high confidence.
The following five non-exclusive classes for relations are considered:
symmetry
anti-symmetry
inversion
implication
composition
This method generally follows the terminology of association rule mining. The patterns are expressed as
\[X_1 \land \cdot \land X_k \implies Y\]where \(X_i\) is of the form \(r_i(h_i, t_i)\), and some of the \(h_i / t_i\) might re-occur in other atoms. The support of a pattern is the number of distinct instantiations of the variables shared by the left- and right-hand side, i.e., the distinct \((x, y)\) pairs for symmetry, anti-symmetry, inversion, and implication, and the distinct \((x, z)\) pairs for composition (where the intermediate entity \(y\) is projected out). The confidence is the proportion of these instantiations where the right-hand side is also true.
Note
With the default
min_support=0, patterns supported by very few pairs, e.g., a single triple, can reach a confidence of 1.0 and thus pass the confidence threshold. Consider setting a minimum support, in particular for small or dense datasets, such asNations.- Parameters:
dataset (Dataset) – The dataset to investigate.
min_support (int) – A minimum support for patterns. Defaults to 0, i.e., no filtering by support; see the note above.
min_confidence (float) – A minimum confidence for the tested patterns.
drop_confidence (bool) – Whether to drop the support/confidence information from the result frame, and also drop duplicates.
parts (Collection[str] | None) – Only use certain parts of the dataset, e.g., train triples. Defaults to using all triples, i.e. {“training”, “validation”, “testing}.
force (bool) – Whether to enforce re-calculation even if a cached version is available.
add_labels (bool) – Whether to add relation labels (if available).
- Return type:
Warning
If you intend to use the relation categorization as input to your model, or hyper-parameter selection, do not include testing triples to avoid leakage!