lenskit.data.RelationshipSet#
- class lenskit.data.RelationshipSet(ds, name, schema, table)#
Bases:
object
Representation for a set of relationship records. This is the class for accessing general relationships, with arbitrarily many entity classes involved and repeated relationships allowed.
For two-entity relationships without duplicates (including relationships formed by coalescing repeated relationships or interactions),
MatrixRelationshipSet
extends this with additional capabilities.Relationship sets can be pickled or serialized, and will not save the entire dataset with them. They are therefore safe to save as component elements during training processes.
- Parameters:
ds (Dataset)
name (str)
schema (RelationshipSchema)
table (pa.Table)
- __init__(ds, name, schema, table)#
- Parameters:
ds (Dataset)
name (str)
schema (RelationshipSchema)
table (Table)
Methods
__init__
(ds, name, schema, table)arrow
(*[, attributes, ids])Get these relationships and their attributes as a PyArrow table.
count
()matrix
(*[, combine])Convert this relationship set into a matrix, coalescing duplicate observations.
pandas
(*[, attributes, ids])Get these relationship and their attributes as a PyArrow table.
Attributes
attribute_names
Query whether these relationships represent interactions.
The name of the relationship class for these relationships.
schema
- arrow(*, attributes=None, ids=False)#
Get these relationships and their attributes as a PyArrow table.
- pandas(*, attributes=None, ids=False)#
Get these relationship and their attributes as a PyArrow table.
- matrix(*, combine=None)#
Convert this relationship set into a matrix, coalescing duplicate observations.
- Parameters:
combine (Literal['count', 'sum', 'mean', 'first', 'last'] | ~collections.abc.Mapping[str, ~typing.Literal['count', 'sum', 'mean', 'first', 'last']] | None) – The method for combining attribute values for repeated relationships or interactions. Can either be a single strategy or a mapping from attribute names to combination strategies.
- Return type: