visions.relations.relations.TypeRelation¶
-
class
visions.relations.relations.
TypeRelation
(type, related_type, inferential, transformer, relationship=<function default_relation>)[source]¶ Relationship encoder between implementations of
visions.types.type.VisionsBaseType
Defines a one to one relationship between two
visions.types.type.VisionsBaseType
implementations, A and B, with respect to an underlying data series. In order to define a relationship we need two methods:is_relationship, determines whether a series of type B can be alternatively represented as type A.
transform, provides a mechanism to convert the series from B -> A.
For example, the series pd.Series([1.0, 2.0, 3.0]) is encoded as a sequence of floats but in reality they are all integers.
Examples
>>> from visions.types import Integer, Float >>> x = pd.Series([1.0, 2.0, 3.0]) >>> state = dict() >>> relation = TypeRelation(Integer, Float) >>> relation.is_relation(x, state) True
>>> relation.transform(x, state) pd.Series([1, 2, 3])
Method generated by attrs for class TypeRelation.
-
__init__
(type, related_type, inferential, transformer, relationship=<function default_relation>)¶ Method generated by attrs for class TypeRelation.
Methods
__init__
(type, related_type, inferential, …)Method generated by attrs for class TypeRelation.
is_relation
(series[, state])- rtype
bool
transform
(series[, state])- rtype
~T