lenskit.data.RelationshipSet#
- class lenskit.data.RelationshipSet(name, vocabularies, 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.
Note
Client code does not need to construct this class; obtain instances from a dataset’s
relationships()
orinteractions()
method.- Stability:
- Caller (see Stability Levels).
- Parameters:
name (str)
vocabularies (dict[str, Vocabulary])
schema (RelationshipSchema)
table (pa.Table)
- __init__(name, vocabularies, schema, table)#
- Parameters:
name (str)
vocabularies (dict[str, Vocabulary])
schema (RelationshipSchema)
table (Table)
Methods
__init__
(name, vocabularies, schema, table)arrow
(*[, attributes, ids])Get these relationships and their attributes as a PyArrow table.
count
()matrix
(*[, row_entity, col_entity])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
entities
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(*, row_entity='user', col_entity='item')#
Convert this relationship set into a matrix, coalescing duplicate observations.
- Parameters:
- Return type: