recpack.scenarios.splitters.TimestampSplitter

class recpack.scenarios.splitters.TimestampSplitter(t, delta_out=None, delta_in=None)

Split data so that the first return value contains interactions in [t-delta_in, t[, and the second those in [t, t+delta_out[.

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

Parameters
  • t (int) – Timestamp to split on in seconds since epoch.

  • delta_out (int, optional) – Seconds past t. Upper bound on the timestamp of interactions in the second return value. Defaults to None (infinity).

  • delta_in (int, optional) – Seconds before t. Lower bound on the timestamp of interactions in the first return value. Defaults to None (infinity).

Methods

split(data)

Splits data so that data_in contains interactions in [t-delta_in, t[, and data_out those in [t, t+delta_out[.

Attributes

identifier

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

name

The name of the splitter.

property identifier

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

property name

The name of the splitter.

split(data: recpack.matrix.interaction_matrix.InteractionMatrix) Tuple[recpack.matrix.interaction_matrix.InteractionMatrix, recpack.matrix.interaction_matrix.InteractionMatrix]

Splits data so that data_in contains interactions in [t-delta_in, t[, and data_out those in [t, t+delta_out[.

Parameters

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

Returns

A 2-tuple containing the data_in and data_out matrices.

Return type

Tuple[InteractionMatrix, InteractionMatrix]