mOWL: A machine learning library with ontologies
Project description
mOWL: Machine Learning Library with Ontologies
mOWL is a library that provides different machine learning methods in which ontologies are used as background knowledge. mOWL is developed mainly in Python, but we have integrated the functionalities of OWLAPI, which is written in Java, for which we use JPype to bind Python with the Java Virtual Machine (JVM).
Table of contents
Installation
Test PyPi (beta version)
pip install -i https://test.pypi.org/simple/ mowl-borg
From GitHub
Installation can be done with the following commands:
git clone https://github.com/bio-ontology-research-group/mowl.git
cd mowl
conda env create -f environment.yml
conda activate mowl
./build_jars.sh
The last line will generate the necessary jar
files to bind Python with the code that runs in the JVM
Examples of use
Basic example
In this example we use the training data (which is an OWL ontology) from the built-in dataset PPIYeasSlimDataset to build a graph representation using the subClassOf axioms.
from mowl.datasets.ppi_yeast import PPIYeastSlimDataset
from mowl.graph.taxonomy.model import TaxonomyParser
dataset = PPIYeastSlimDataset()
parser = TaxonomyParser(dataset.ontology, bidirectional_taxonomy = True)
edges = parser.parse()
The projected edges
is an edge list of a graph. One use of this may be to generate random walks:
from mowl.walking.deepwalk.model import DeepWalk
walker = DeepWalk(edges,
100, # number of walks
20, # length of each walk
0.2, # probability of restart
workers = 4, # number of usable CPUs
)
walker.walk()
walks = walker.walks
Ontology to graph
In the previous example we called the class TaxonomyParser
to perform the graph projection. However, there are more ways to perform the projection. We include the following four:
- TaxonomyParser: "taxonomy"
- TaxonomyWithRelsParser: "taxonomy_rels"
- DL2VecParser: "dl2vec"
- OWL2VecParser: "owl2vec_star"
Instead of instantianting each of them separately, there is the following factory method:
from mowl.graph.factory import parser_factory
parser = parser_factory("taxonomy_rels", dataset.ontology, bidirectional_taxonomy = True)
Now parser
will be an instance of the TaxonomyWithRelsParser
class. The string parameters for each method are listed above.
For the random walks method we have a similar factory method that can be found in mowl.walking.factory
and is called walking_factory
.
List of contributors
- Fernando Zhapa
- Maxat Kulmanov
- Sarah Alghamdi
- Robert Hoehndorf
- Carsten Jahn
- Sonja Katz
- Marco Anteghini
- Francesco Gualdi
- luis-sribeiro
- Leduin Cuenca (logo)
License
Documentation
Full documentation and API reference can be found in our ReadTheDocs website.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mowl_borg-0.0.26-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92895f9ab7667c257f4cf2b4ae152c99c8f4f2257c2977800693d2f681b44cf2 |
|
MD5 | e762d95f70e9c2016925a7f193fd2cb5 |
|
BLAKE2b-256 | 2881e7a26f5496245bf6a0ffba01e73d4197ba3ec0f14eb1128cee0ac10bdccc |