recpack.preprocessing.filters.MaxItemsPerUser

class recpack.preprocessing.filters.MaxItemsPerUser(max_items_per_user: int, item_ix: str, user_ix: str, count_duplicates: bool = False)

Require that a user has interacted with no more than max_items_per_user items.

This way you can remove users that show extreme behaviour.

Parameters
  • max_items_per_user (int) – Maximum number of items allowed.

  • item_ix (str) – Name of the column in which item identifiers are listed.

  • user_ix (str) – Name of the column in which user identifiers are listed.

  • count_duplicates (bool) – Count multiple interactions with the same item, defaults to False

Methods

apply(df)

Apply Filter to the DataFrame passed.

apply_all(*dfs)

Apply the filter to a list of pandas DataFrames.

apply(df)

Apply Filter to the DataFrame passed.

Parameters

df (pd.DataFrame) – DataFrame to filter

apply_all(*dfs: pandas.core.frame.DataFrame) List[pandas.core.frame.DataFrame]

Apply the filter to a list of pandas DataFrames.

The filter is applied independently to each of the DataFrames.

Returns

The list of processed DataFrames

Return type

List[pd.DataFrame]