Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring (removed owlapy), verbalization, documentation update and some fixes #310

Merged
merged 9 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Learning algorithms:
- **EvoLearner** → [EvoLearner: Learning Description Logics with Evolutionary Algorithms](https://dl.acm.org/doi/abs/10.1145/3485447.3511925)
- **NCES2** → (soon) [Neural Class Expression Synthesis in ALCHIQ(D)](https://papers.dice-research.org/2023/ECML_NCES2/NCES2_public.pdf)
- **NCES** → [Neural Class Expression Synthesis](https://link.springer.com/chapter/10.1007/978-3-031-33455-9_13)
- **NERO** → [Learning Permutation-Invariant Embeddings for Description Logic Concepts](https://link.springer.com/chapter/10.1007/978-3-031-30047-9_9)
- **NERO** → (soon) [Learning Permutation-Invariant Embeddings for Description Logic Concepts](https://link.springer.com/chapter/10.1007/978-3-031-30047-9_9)
- **CLIP** → (soon) [Learning Concept Lengths Accelerates Concept Learning in ALC](https://link.springer.com/chapter/10.1007/978-3-031-06981-9_14)
- **CELOE** → [Class Expression Learning for Ontology Engineering](https://www.sciencedirect.com/science/article/abs/pii/S1570826811000023)
- **OCEL** → A limited version of CELOE
Expand All @@ -34,9 +34,9 @@ from ontolearn.knowledge_base import KnowledgeBase
from ontolearn.concept_learner import CELOE, OCEL, EvoLearner, Drill
from ontolearn.learning_problem import PosNegLPStandard
from ontolearn.metrics import F1
from ontolearn.owlapy.model import OWLNamedIndividual, IRI
from owlapy.model import OWLNamedIndividual, IRI
from ontolearn.utils import setup_logging
from ontolearn.owlapy.render import DLSyntaxObjectRenderer
from owlapy.render import DLSyntaxObjectRenderer
setup_logging()
renderer = DLSyntaxObjectRenderer()
max_runtime, topk=1, 3
Expand All @@ -63,6 +63,9 @@ Fore more please refer to the [examples](https://github.com/dice-group/Ontolear

## Deployment

```shell
pip install gradio
```

To deploy **EvoLearner** on the **Family** knowledge graph. Available models to deploy: **EvoLearner**, **NCES**, **CELOE** and **OCEL**.
```shell
Expand Down
23 changes: 14 additions & 9 deletions deploy_cl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pandas as pd
import torch
import gradio as gr
from argparse import ArgumentParser
import random
import os
Expand All @@ -15,8 +14,14 @@
from ontolearn.learning_problem import PosNegLPStandard
from ontolearn.refinement_operators import ModifiedCELOERefinement
from ontolearn.value_splitter import EntropyValueSplitter, BinningValueSplitter
from ontolearn.owlapy.model import OWLNamedIndividual, IRI
from ontolearn.owlapy.render import DLSyntaxObjectRenderer
from owlapy.model import OWLNamedIndividual, IRI
from owlapy.render import DLSyntaxObjectRenderer

try:
import gradio as gr
except ImportError as e:
raise ImportError("Gradio not found! Please install gradio to use this script --> `pip install gradio`")


metrics = {'F1': F1,
'Accuracy': Accuracy,
Expand Down Expand Up @@ -141,15 +146,15 @@ def predict(positive_examples, negative_examples, random_examples, size_of_examp
with gr.Row():
i6 = gr.Checkbox(label="Terminate on goal", value=True)
i8 = gr.Checkbox(label="Use data properties", value=True)
i9 = gr.Checkbox(label="Use card restrictions", value=True)
i9 = gr.Checkbox(label="Use cardinality restrictions for object properties", value=True)
i10 = gr.Checkbox(label="Use inverse", value=False)
with gr.Row():
i7 = gr.Number(label="Maximum runtime", value=600)
i11 = gr.Number(label="Tournament size", value=7)
i13 = gr.Number(label="Population size", value=800)
with gr.Row():
i14 = gr.Number(label="Num generations", value=200)
i12 = gr.Number(label="Card limit", value=10)
i12 = gr.Number(label="Cardinality limit for object properties", value=10)
i15 = gr.Number(label="Height limit", value=17)
gr.Markdown("Set arguments for the fitness function (LinearPressureFitness)")
with gr.Box():
Expand Down Expand Up @@ -291,8 +296,8 @@ def predict(positive_examples, negative_examples, random_examples: bool, size_of
info="For the value splitter: BinningValueSplitter")
i18 = gr.Number(label="Maximum child length", value=10, info="\n")
with gr.Row():
i22 = gr.Checkbox(label="Use card restrictions", value=True)
i26 = gr.Number(label="Card limit", value=10)
i22 = gr.Checkbox(label="Use cardinality restrictions for object properties", value=True)
i26 = gr.Number(label="Cardinality limit for object properties", value=10)
with gr.Row():
i19 = gr.Checkbox(label="Use negation", value=True)
i20 = gr.Checkbox(label="Use all constructors", value=True)
Expand Down Expand Up @@ -405,8 +410,8 @@ def predict(positive_examples, negative_examples, random_examples: bool, size_of
info="For the value splitter: BinningValueSplitter")
i16 = gr.Number(label="Maximum child length", value=10, info="\n")
with gr.Row():
i20 = gr.Checkbox(label="Use card restrictions", value=True)
i24 = gr.Number(label="Card limit", value=10)
i20 = gr.Checkbox(label="Use cardinality restrictions for object properties", value=True)
i24 = gr.Number(label="Cardinality limit for object properties", value=10)
with gr.Row():
i17 = gr.Checkbox(label="Use negation", value=True)
i18 = gr.Checkbox(label="Use all constructors", value=True)
Expand Down
21 changes: 14 additions & 7 deletions docs/usage/01_introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@

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

For the core module [owlapy](ontolearn.owlapy) Ontolearn is based on [Owlready2](https://owlready2.readthedocs.io/en/latest/index.html),
a package for manipulating OWL 2.0 ontologies in Python. In addition, we have implemented
a higher degree of code for manipulation OWL 2.0 ontologies, in pursuit of making it
easier, more flexible and of course, having this all in Python. This adaptation of
Owlready2 library made it possible to build more complex algorithms.

Ontolearn started with the goal of using _Explainable Structured Machine Learning_
in OWL 2.0 ontologies and this
exactly what our library offers. The main contribution are the exclusive concept learning
algorithms that are part of this library. Currently, we have 4 fully functioning algorithms that
learn concept in description logics. Papers can be found [here](09_further_resources.md).

Ontolearn can do the following:
For the base (core) module of Ontolearn we use [owlapy](https://github.com/dice-group/owlapy)
combined with [Owlready2](https://owlready2.readthedocs.io/en/latest/index.html). _Owlapy_ is a python package
based on owlapi and implemented by us, the Ontolearn team. For the sake of modularization we
have moved it in a separate repository. On the other side _Owlready2_ is a package for manipulating
OWL 2.0 ontologies in Python. So in the end we have implemented
a higher degree of code for manipulation OWL 2.0 ontologies, in pursuit of making it
easier to implement and understand, and of course, having this all in Python. This adaptation of
Owlready2 library made it possible to build more complex algorithms.

---------------------------------------

**Ontolearn (including owlapy) can do the following:**

- Load/save ontologies in RDF/XML, OWL/XML.
- Modify ontologies by adding/removing axioms.
Expand All @@ -38,6 +43,8 @@ Ontolearn can do the following:
- Reason over an ontology.
- Other convenient functionalities like converting OWL class expressions to SPARQL or DL syntax.

------------------------------------

The rest of the content is build as a top-to-bottom guide, but nevertheless self-containing, where
you can learn more in depth about the capabilities of Ontolearn.

Expand Down
37 changes: 18 additions & 19 deletions docs/usage/02_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ One such system for virtual python environments is
We have good experience with it and make use of conda in the
[Installation from source](#installation-from-source) step.

## Installation via _pip_

Released versions of Ontolearn can be installed using `pip`, the
Package Installer for Python. It comes as part of Python. Please
research externally (or use `conda create` command below) on how to
create virtual environments for Python programs.

```shell
pip install ontolearn
```

This will download and install the latest release version of Ontolearn
and all its dependencies from <https://pypi.org/project/ontolearn/>.

## Installation From Source

To download the Ontolearn source code, you will also need to have a
Expand All @@ -34,11 +48,11 @@ installation links to get started with the library.
git clone https://github.com/dice-group/Ontolearn.git
cd Ontolearn
```
* Load the dependencies into a new conda environment called "temp" (you can name it however you like)

* Create a conda environment using the `environment.yml` file.
```shell
conda create --name temp python=3.8
conda activate temp
conda env update --name temp
conda env create -f environment.yml
conda activate ontolearn
```
* Install the development links so that Python will find the library
```shell
Expand Down Expand Up @@ -69,21 +83,6 @@ to successfully pass all the tests:
pytest
```


## Installation via _pip_

Released versions of Ontolearn can also be installed using `pip`, the
Package Installer for Python. It comes as part of Python. Please
research externally (or use above `conda create` command) on how to
create virtual environments for Python programs.

```shell
pip install ontolearn
```

This will download and install the latest release version of Ontolearn
and all its dependencies from <https://pypi.org/project/ontolearn/>.

## Download External Files

Some resources like pre-calculated embeddings or `pre_trained_agents` and datasets (ontologies)
Expand Down
Loading
Loading