NXTfusion.NXTfusion module¶
-
class
NXTfusion.NXTfusion.
Entity
(name, domain, dtype=<class 'numpy.int32'>)[source]¶ Bases:
object
Class representing the Entity concept.
-
__getitem__
(self, x: str)¶ Method that returns the numeric value internally associated to each object in the Entity class.
- Parameters
x (str) – String name of a specific object in the Entity.
- Returns
primary key int
-
__getitem__
(self, x: int)¶ Method that returns the str name of the object with primary key x.
- Parameters
x (int) – Primary key (unique id) of an object in the domain represented by the Entity.
- Returns
name of the object : str
-
__init__
(name, domain, dtype=<class 'numpy.int32'>)[source]¶ Constructor for the Entity class.
- Parameters
name (str) – Name of the Entity (use a mnemonic name describing the class of objects represented by the Entity)
domain (iterable (list) containing str) – List of the possible objects belonging to this class (e.g. patients IDs, proteins Uniprot identifiers, …). It is an unique identifier naming (with a string) all the objects composing the domain of the Entity.
dtype (np.dtype) – Smallest possible numpy type able to uniquely enumerate all the objects. len(domain) < max_number_representable(dtype).
-
-
class
NXTfusion.NXTfusion.
Relation
(name: str, domain1: NXTfusion.NXTfusion.Entity, domain2: NXTfusion.NXTfusion.Entity, data, task: str, loss: torch.nn.modules.module.Module, relationWeight: float, side1=None, side2=None, path=None)[source]¶ Bases:
dict
Class that represent a relation (matrix in MF terms) with all its parameters and functions.
-
__init__
(name: str, domain1: NXTfusion.NXTfusion.Entity, domain2: NXTfusion.NXTfusion.Entity, data, task: str, loss: torch.nn.modules.module.Module, relationWeight: float, side1=None, side2=None, path=None)[source]¶ Constructor for the Relation class..
- Parameters
name (str) – Mnemonic name of the specific relation/matrix.
domain1 (Entity) – Entity1 involved in the relation (on dimension 0)
domain2 (Entity) – Entity2 involved in the relation (on dimension 1)
data (DataMatrix) – DataMatrix object containing the matrix describing this relation
task (str ["regression", "binary"]) – Type of prediction task associated to this relation. “Regression” for real valued predictions, “binary” for binary classification.
loss (NX.NXLosses or t.nn.Module) – Pytorch-like loss module corresponding to the loss that must be used to compute the reconstruction error for this relation.
relationWeight (float) – A relation-specific weight that will multiply the loss score during training.
-
-
class
NXTfusion.NXTfusion.
MetaRelation
(name, domain1, domain2, side1=None, side2=None, relations=[], prediction=False)[source]¶ Bases:
object
Constructor for the Relation class. The Meta Relation represents multi-relations between the same entities (used for example in tensor factorization).
As a convention, we recommend to use names in the form ENT1-ENT2.
The domains must be the same for each relation in it, since the MetaRelation defines a tensor where the dimension 0 and 1 represent the same entities for all the matrices involved in the tensor. Can allow side info (common to all relations in it).
-
__getitem__
(self, x: str)¶ Getitem method that searches by Relation.name
- Parameters
x (str) – The name of a Relation in this MetaRelation
- Returns
The target Relation or None
-
__getitem__
(self, x: int)¶ Getitem method that searches by position of the target Relation in the tensor/MetaRelation.
- Parameters
x (str) – The position (index) of a Relation in this MetaRelation
- Returns
The target Relation or None
-
__init__
(name, domain1, domain2, side1=None, side2=None, relations=[], prediction=False)[source]¶ Constructor for the MetaRelation class.
- Parameters
name (str) – Mnemonic name of the specific relation/matrix.
domain1 (Entity) – Entity1 involved in the relation (on dimension 0)
domain2 (Entity) – Entity2 involved in the relation (on dimension 1)
relations (list of NX.Relation objects) – List of the relations involved in this MetaRelation (tensor)
-
append
(r)[source]¶ Method that adds a Relation object to an existing MetaRelation :param r: :type r: Relation
-
next
()¶
-
-
class
NXTfusion.NXTfusion.
ERgraph
(entityList: list, name='')[source]¶ Bases:
list
Class that represents the entire Entity-Relation graphs, namely a list of MetaRelations. Each MetaRelation might contain multiple Relations.
-
__contains__
(self, x: int)¶ Function that determines whether a specific MetaRelation object is present in the graph.
- Parameters
x (MetaRelation) – A MetaRelation object.
- Returns
bool (Is x present?)
-
__contains__
(self, x: str)¶ Function that determines whether a specific MetaRelation.name is present in the graph.
- Parameters
x (str) – A MetaRelation str name.
- Returns
bool (Is x present?)
-