recpack.preprocessing.filters.NMostPopular

class recpack.preprocessing.filters.NMostPopular(N: int, item_ix: str)

Retain only the N most popular items.

Note: All interactions count, also if a user interacted with the same item 1000 times.

Parameters
  • N (int) – Number of items to retain.

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

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]