Input and Output

PyKEEN

Entry points for PyKEEN.

PyKEEN is a machine learning library for knowledge graph embeddings that supports node clustering, link prediction, entity disambiguation, question/answering, and other tasks with knowledge graphs. It provides an interface for registering plugins using Python’s entrypoints under the pykeen.triples.extension_importer and pykeen.triples.prefix_importer groups. More specific information about how the Bio2BEL plugin is loaded into PyKEEN can be found in Bio2BEL’s setup.cfg under the [options.entry_points] header.

The following example shows how you can parse/load the triples from a Bio2BEL repository using the bio2bel prefix:

# Example 1A: Make triples factory
from pykeen.triples import TriplesFactory
tf = TriplesFactory(path='bio2bel:mirtarbase')

# Example 1B: Use directly in the pipeline, which automatically invokes training/testing set stratification
from pykeen.pipeline import pipeline
results = pipeline(
    dataset='bio2bel:mirtarbase',
    model='TransE',
)
bio2bel.io.pykeen.ensure_triples(module_name)[source]

Load a Bio2BEL repository.

Parameters

module_name (str) – The name of the bio2bel repository (with no prefix)

Return type

ndarray

Returns

A three column array with head, relation, and tail in each row

Automation

Automation of installation and execution of Bio2BEL packages.

bio2bel.io.automate.ensure_tsv(name, *, manager_kwargs=None)[source]

Generate/save a TSV from the Bio2BEL package using pybel.to_tsv() and return its path.

The resulting file is cached within the bio2bel package’s data directory. If it already exists, the path is directly returned with no other code being run.

Parameters
  • name (str) – The name of the Bio2BEL package

  • manager_kwargs (Optional[Mapping[str, Any]]) – Optional mapping to give as keyword arguments to the manager upon instantiation.

Return type

str

Returns

The path to the TSV file generated (inside the Bio2BEL directory) or

bio2bel.io.automate.ensure_graph(name, *, manager_kwargs=None)[source]

Generate, cache, and return the BEL graph for a given Bio2BEL package.

If it has already been cached, it is loaded directly.

Parameters
  • name (str) – The name of the Bio2BEL package

  • manager_kwargs (Optional[Mapping[str, Any]]) – Optional mapping to give as keyword arguments to the manager upon instantiation.

Return type

BELGraph

bio2bel.io.automate.ensure_bio2bel_installation(name)[source]

Import a Bio2BEL package, or install it.

Returns

If the package was already installed

Return type

Tuple[bool, module]

Returns

A module object representing the Bio2BEL package