sbrunk / Ontolearn

Ontolearn is an open-source software library for explainable structured machine learning in Python. It learns OWL class expressions from positive and negative examples.

Home Page:https://ontolearn-docs-dice-group.netlify.app/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ontolearn

Ontolearn is an open-source software library for explainable structured machine learning in Python.

Installation

Installation from source

git clone https://github.com/dice-group/Ontolearn.git
cd Ontolearn
conda create --name temp python=3.8
conda activate temp
conda env update --name temp
python -c 'from setuptools import setup; setup()' develop
python -c "import ontolearn"
python -m pytest tests # Partial test with pytest
tox  # full test with tox

Installation via pip

pip install ontolearn  # currently it is only a place holder https://pypi.org/project/ontolearn/

Usage

See the manual, tests and examples folder for details.

from ontolearn.concept_learner import CELOE
from ontolearn.model_adapter import ModelAdapter
from owlapy.model import OWLNamedIndividual, IRI
from owlapy.namespaces import Namespaces
from owlapy.render import DLSyntaxObjectRenderer
from examples.experiments_standard import ClosedWorld_ReasonerFactory

NS = Namespaces('ex', 'http://example.com/father#')

positive_examples = {OWLNamedIndividual(IRI.create(NS, 'stefan')),
                     OWLNamedIndividual(IRI.create(NS, 'markus')),
                     OWLNamedIndividual(IRI.create(NS, 'martin'))}
negative_examples = {OWLNamedIndividual(IRI.create(NS, 'heinz')),
                     OWLNamedIndividual(IRI.create(NS, 'anna')),
                     OWLNamedIndividual(IRI.create(NS, 'michelle'))}

# Only the class of the learning algorithm is specified
model = ModelAdapter(learner_type=CELOE,
                     reasoner_factory=ClosedWorld_ReasonerFactory,
                     path="KGs/father.owl")

model.fit(pos=positive_examples,
          neg=negative_examples)

dlsr = DLSyntaxObjectRenderer()

for desc in model.best_hypotheses(1):
    print('The result:', dlsr.render(desc.concept), 'has quality', desc.quality)

Download external files (.link files)

Some resources like pre-calculated embeddings or pre_trained_agents are not included in the Git repository directly. Use the following command to download them from our data server.

./big_gitext/download_big.sh examples/pre_trained_agents.zip.link
./big_gitext/download_big.sh -A  # to download them all into examples folder

To update or upload resource files, follow the instructions here and use the following command.

./big_gitext/upload_big.sh pre_trained_agents.zip

Building (sdist and bdist_wheel)

tox -e build

Building the docs

tox -e docs

Contribution

Feel free to create a pull request

Simple Linting

Run

tox -e lint --

This will run flake8 on the source code.

For any further questions, please contact: onto-learn@lists.uni-paderborn.de

About

Ontolearn is an open-source software library for explainable structured machine learning in Python. It learns OWL class expressions from positive and negative examples.

https://ontolearn-docs-dice-group.netlify.app/index.html

License:GNU Affero General Public License v3.0


Languages

Language:Python 98.0%Language:Shell 1.9%Language:Dockerfile 0.1%