dice-group / 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.
https://ontolearn-docs-dice-group.netlify.app/index.html
MIT License
32 stars 9 forks source link

Make use of a SPARQL endpoint for all CEL algorithms #374

Open MichaelRoeder opened 2 months ago

MichaelRoeder commented 2 months ago

User story

As a user of knowledge graphs, I already have my knowledge graph within a triple store with a SPARQL interface. However, for some of the CEL algorithms, it seems like I have to export my data into an OWL file to run them, just so that they load the file again into memory. Would it be possible to just provide a SPARQL endpoint as it is done in the tdl example?

alkidbaci commented 2 months ago

Hi Michael, as you already mentioned, like in the tdl example you just have to pass a TripleStoreKnowledgeBase instead of KnowledgeBase to any CEL algorithms and there is no need to have the knowledge graph locally. Currently, some bugs related to triple store implementation have emerged and there may be errors when executing concept learners. We will fix them soon.

Demirrr commented 2 months ago

For the record, tDL and DRILL can be currently used with an endpoint of a triplestore, e.g.

ontolearn-webservice --endpoint_triple_store http://0.0.0.0:9080/sparql

import json
import requests
with open(f"LPs/Mutagenesis/lps.json") as json_file:
    learning_problems = json.load(json_file)["problems"]
for str_target_concept, examples in learning_problems.items():
    response = requests.get('http://0.0.0.0:8000/cel',
                            headers={'accept': 'application/json', 'Content-Type': 'application/json'},
                            json={"pos": examples['positive_examples'],
                                  "neg": examples['negative_examples'],
                                  "model": "TDL",
                                  })