plot_er

plot_er(pipeline_result, *, model=None, entities=None, relations=None, apply_limits=True, margin=0.4, plot_entities=True, plot_relations=None, annotation_x_offset=0.02, annotation_y_offset=0.03, entity_embedding_getter=None, relation_embedding_getter=None, ax=None, subtitle=None, **kwargs)[source]

Plot the reduced entities and relation vectors in 2D.

Parameters:
  • pipeline_result – The result returned by pykeen.pipeline.pipeline().

  • model (Optional[str]) – The dimensionality reduction model from sklearn. Defaults to PCA. Can also use KPCA, GRP, SRP, TSNE, LLE, ISOMAP, MDS, or SE.

  • entities (Optional[Set[str]]) – A subset of entities to plot

  • relations (Optional[Set[str]]) – A subset of relations to plot

  • apply_limits (bool) – Should the x and y limits be applied?

  • margin (float) – The margin size around the minimum/maximum x and y values

  • plot_entities (bool) – If true, plot the entities based on their reduced embeddings

  • plot_relations (Optional[bool]) – By default, this is only enabled on translational distance models like pykeen.models.TransE.

  • annotation_x_offset (float) – X offset of label from entity position

  • annotation_y_offset (float) – Y offset of label from entity position

  • entity_embedding_getter – A function that takes a model and returns its entity embeddings. If none, defaults to _default_entity_embedding_getter(), which just gets model.entity_embeddings. Note, the default only works with old-style PyKEEN models.

  • relation_embedding_getter – A function that takes a model and returns its relation embeddings. If none, defaults to _default_relation_embedding_getter(), which just gets model.relation_embeddings. Note, the default only works with old-style PyKEEN models.

  • ax – The matplotlib axis, if pre-defined

  • subtitle (Optional[str]) – A user-defined subtitle. Is inferred if not given. Pass an empty string to not use a subtitle.

  • kwargs – The keyword arguments passed to __init__() of the reducer class (e.g., PCA, TSNE)

Returns:

The axis

Raises:

ValueError – if entity plotting and relation plotting are both turned off

Warning

Plotting relations and entities on the same plot is only meaningful for translational distance models like TransE.