recpack.scenarios.splitters.MostRecentSplitter

class recpack.scenarios.splitters.MostRecentSplitter(n: int)

Splits the n most recent interactions of a user into the second return value, and earlier interactions into the first.

Parameters

n (int) – Number of most recent actions to assign to the second return value. If n is negative, all but the n earliest interactions are assigned to the second return value.

Methods

split(data)

Splits the n most recent interactions of a user into data_out, and earlier interactions into data_in.

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 the n most recent interactions of a user into data_out, and earlier interactions into data_in.

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]