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.

evaluation_model

Returns the evaluation model.

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.

metrics

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)

evaluate(*args, **kwargs)

from_pretrained(file_name)

This method loads a pretrained model from a file.

score(axiom)

Returns the score of the given axiom.

set_evaluator(evaluator, *args, **kwargs)

This method sets the evaluator for the model.

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

Added in version 0.2.0.

class_index_dict

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

Return type:

dict

evaluation_model

Returns the evaluation model. In models relying on Word2Vec embeddings, this method calls an auxiliary evaluation model for scoring. Methods using KGEs or Geometric Embeddings would return the model itself.

Added in version 1.0.0.

individual_embeddings

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

Return type:

dict

Added in version 0.2.0.

individual_index_dict

Dictionary with individual names as keys and indexes as values.

Return type:

dict

metrics

Added in version 1.0.0.

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

Added 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.

Added in version 0.2.0.

eval_fn(*args, **kwargs)[source]
evaluate(*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.

Added 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.

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

set_evaluator(evaluator, *args, **kwargs)[source]

This method sets the evaluator for the model.

Parameters:

evaluator (mowl.evaluation.base.Evaluator) – Evaluator object.

Added in version 1.0.0.

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

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