Model

class mowl.base_models.Model(dataset, model_filepath=None)[source]

Bases: object

Abstract model class.

Parameters:
  • dataset (mowl.datasets.base.Dataset) – Dataset object.

  • model_filepath (str, optional) – Path for saving the model. Defaults to a temporary file path.

Changed in version 0.1.0: Parameter model_filepath added in the base class for all models. Optional parameter that will use temporary files in case it is not set.

Attributes Summary

class_embeddings

Returns a dictionary with class names as keys and class embeddings as values.

class_index_dict

Dictionary with class names as keys and class indexes as values.

individual_embeddings

Returns a dictionary with individual names as keys and individual embeddings as values.

individual_index_dict

Dictionary with individual names as keys and indexes as values.

model_filepath

Path for saving the model.

object_property_embeddings

Returns a dictionary with object property names as keys and object property embeddings as values.

object_property_index_dict

Dictionary with object property names as keys and object property indexes as values.

Methods Summary

add_axioms(*axioms)

This method adds axioms to the dataset contained in the model and reorders the embedding information for each entity accordingly.

eval_fn(*args, **kwargs)

from_pretrained(file_name)

This method loads a pretrained model from a file.

score(axiom)

Returns the score of the given axiom.

train(*args, **kwargs)

Abstract method for training the model.

Attributes Documentation

class_embeddings

Returns a dictionary with class names as keys and class embeddings as values.

Return type:

dict

New in version 0.2.0.

class_index_dict

Dictionary with class names as keys and class indexes as values.

Return type:

dict

individual_embeddings

Returns a dictionary with individual names as keys and individual embeddings as values.

Return type:

dict

New in version 0.2.0.

individual_index_dict

Dictionary with individual names as keys and indexes as values.

Return type:

dict

model_filepath

Path for saving the model.

Return type:

str

object_property_embeddings

Returns a dictionary with object property names as keys and object property embeddings as values.

Return type:

dict

New in version 0.2.0.

object_property_index_dict

Dictionary with object property names as keys and object property indexes as values.

Return type:

dict

Methods Documentation

add_axioms(*axioms)[source]

This method adds axioms to the dataset contained in the model and reorders the embedding information for each entity accordingly. New entites are initalized with random embedding.

Parameters:

axioms (org.semanticweb.owlapi.model.OWLAxiom) – Axioms to be added to the dataset.

New in version 0.2.0.

eval_fn(*args, **kwargs)[source]
from_pretrained(file_name)[source]

This method loads a pretrained model from a file.

Parameters:

file_name (str) – Path to the pretrained model file.

New in version 0.2.0.

score(axiom)[source]

Returns the score of the given axiom.

Parameters:

axiom (org.semanticweb.owlapi.model.OWLAxiom) – The axiom to score.

New in version 0.2.0: Axiom scoring method added to the base class.

train(*args, **kwargs)[source]

Abstract method for training the model. This method must be implemented in children classes