streamsight.settings.TimestampSplitter

class streamsight.settings.TimestampSplitter(t: int, t_lower: int | None = None, t_upper: int | None = None)

Bases: Splitter

Splits data by timestamp.

Split data so that the first return value contains interactions in [t-t_lower, t), and the second those in [t, t+t_upper].

If t_lower or t_upper are omitted, they are assumed to have a value of infinity. A user can occur in both return values.

Attribute definition

  • past_interaction: List of unlabeled data. Interval is [0, t).

  • future_interaction: Data used for training the model. Interval is [t, t+t_upper) or [t,inf].

param t:

Timestamp to split on in seconds since epoch.

type t:

int

param t_lower:

Seconds before t. Lower bound on the timestamp of interactions in the first return value. Defaults to None (infinity).

type t_lower:

int, optional

param t_upper:

Seconds past t. Upper bound on the timestamp of interactions in the second return value. Defaults to None (infinity).

type t_upper:

int, optional

__init__(t: int, t_lower: int | None = None, t_upper: int | None = None)

Methods

__init__(t[, t_lower, t_upper])

split(data)

Splits data so that past_interaction contains interactions in [t-t_lower, t), and future_interaction those in [t, t+t_upper].

Attributes

identifier

String identifier of the splitter object, contains name and parameter values.

name

The name of the splitter.

_abc_impl = <_abc._abc_data object>
property identifier

String identifier of the splitter object, contains name and parameter values.

property name

The name of the splitter.

split(data: InteractionMatrix) Tuple[InteractionMatrix, InteractionMatrix]

Splits data so that past_interaction contains interactions in [t-t_lower, t), and future_interaction those in [t, t+t_upper].

Parameters:

data (InteractionMatrix) – Interaction matrix to be split. Must contain timestamps.

Returns:

A 2-tuple containing the past_interaction and future_interaction matrices.

Return type:

Tuple[InteractionMatrix, InteractionMatrix]