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
39 stars 9 forks source link

Retrieval of OWLDataSomeValuesFrom #385

Closed Demirrr closed 5 months ago

Demirrr commented 6 months ago

OWL Object Representation

OWLObjectIntersectionOf((OWLDataSomeValuesFrom(property=OWLDataProperty(IRI('http://dl-learner.org/mutagenesis#','act')),filler=OWLDatatypeRestriction(OWLDatatype(IRI('http://www.w3.org/2001/XMLSchema#','double')), (OWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, OWLLiteral(0.014999999664723873)),))), OWLDataSomeValuesFrom(property=OWLDataProperty(IRI('http://dl-learner.org/mutagenesis#','logp')),filler=OWLDatatypeRestriction(OWLDatatype(IRI('http://www.w3.org/2001/XMLSchema#','double')), (OWLFacetRestriction(OWLFacet.MAX_INCLUSIVE, OWLLiteral(1.2350000143051147)),)))))

DL Representation

(∃ act.xsd:double[≤ 0.014999999664723873]) ⊓ (∃ logp.xsd:double[≤ 1.2350000143051147])

Retrieval Result with KnowlegeBase

frozenset({OWLNamedIndividual(IRI('http://dl-learner.org/mutagenesis#','d17')), OWLNamedIndividual(IRI('http://dl-learner.org/mutagenesis#','d70')), OWLNamedIndividual(IRI('http://dl-learner.org/mutagenesis#','d181')), OWLNamedIndividual(IRI('http://dl-learner.org/mutagenesis#','d150'))})

Let's take a look at respective assertion about http://dl-learner.org/mutagenesis#d17 in the input KG

    <owl:NamedIndividual rdf:about="http://dl-learner.org/mutagenesis#d17">
     <logp rdf:datatype="http://www.w3.org/2001/XMLSchema#double">2.52</logp>
    </owl:NamedIndividual>

Is there any reason of returning this individual given it does not satisfiy the second condition ?

Edit: KnowledgeBase is being used

Demirrr commented 5 months ago

An example from carcinogenesis dataset.

OWLNamedIndividual(IRI('http://dl-learner.org/carcinogenesis#','d204')) is not in the retrieval of expression:∃ amesTestPositive.{False} The CE is an instance of OWLDataHasValue(property=...,value=OWLLiteral(False))

alkidbaci commented 5 months ago

For the mutagenesis case, the individual d17 has the following relations:

<owl:NamedIndividual rdf:about="http://dl-learner.org/mutagenesis#d17">
        <rdf:type rdf:resource="http://dl-learner.org/mutagenesis#Compound"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_1"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_10"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_11"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_12"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_13"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_14"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_15"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_16"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_17"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_18"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_2"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_3"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_4"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_5"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_6"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_7"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_8"/>
        <hasAtom rdf:resource="http://dl-learner.org/mutagenesis#d17_9"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2120"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2121"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2122"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2123"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2124"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2125"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2126"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2127"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2128"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2129"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2130"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2131"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2132"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2133"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2134"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2135"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2136"/>
        <hasBond rdf:resource="http://dl-learner.org/mutagenesis#bond2137"/>
        <hasStructure rdf:resource="http://dl-learner.org/mutagenesis#benzene-1131"/>
        <hasStructure rdf:resource="http://dl-learner.org/mutagenesis#nitro-1133"/>
        <hasStructure rdf:resource="http://dl-learner.org/mutagenesis#ring_size_6-1132"/>
        <act rdf:datatype="http://www.w3.org/2001/XMLSchema#double">-3.0</act>
        <hasFifeExamplesOfAcenthrylenes rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasFifeExamplesOfAcenthrylenes>
        <hasThreeOrMoreFusedRings rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">false</hasThreeOrMoreFusedRings>
        <logp rdf:datatype="http://www.w3.org/2001/XMLSchema#double">0.87</logp>
        <lumo rdf:datatype="http://www.w3.org/2001/XMLSchema#double">-0.529</lumo>
    </owl:NamedIndividual>

Notice that the logp dataproperty has the value 0.87 which means that the classification is correct. Can you make sure this is also the case in your mutagenesis ontology, (maybe you confused it with individual d170)


An example from carcinogenesis dataset.

OWLNamedIndividual(IRI('http://dl-learner.org/carcinogenesis#','d204')) is not in the retrieval of expression:∃ amesTestPositive.{False} The CE is an instance of OWLDataHasValue(property=...,value=OWLLiteral(False))

I tested that CE on carcinogenesis using the following code and individual d204 was among the printed result.

kb = KnowledgeBase(path="../../KGs/Carcinogenesis/carcinogenesis.owl")

ce = OWLDataHasValue(property=OWLDataProperty(IRI.create("http://dl-learner.org/carcinogenesis#amesTestPositive")),value=OWLLiteral(False))
print(list(kb.individuals(ce)))

I am wondering why it is not showing in your case :thinking:

Demirrr commented 5 months ago

Thank you. Which branch have you used ?

alkidbaci commented 5 months ago

develop branch

Demirrr commented 5 months ago

Can you make sure this is also the case in your mutagenesis ontology, (maybe you confused it with individual d170)

I guess you are right.