recpack.postprocessing.postprocessors.Postprocessor

class recpack.postprocessing.postprocessors.Postprocessor

Class to postprocess a CSR Response Matrix.

Postprocessing applies filters to the given input (algorithm output) data.

In order to apply filters they should be added using add_filter(). The filters and the two other steps get applied during process() and process_many().

Methods

add_filter(_filter[, index])

Add a post-processing filter.

process(X_pred)

param X_pred

csr_matrix containing recommended user-item pairs.

process_many(*X_preds)

Process all CSR Matrices passed as arguments.

add_filter(_filter: recpack.postprocessing.filters.PostFilter, index: Optional[int] = None)

Add a post-processing filter.

Parameters
  • _filter (PostFilter) – filter to be applied

  • index (int, optional) – Index at which to insert the filter. Follows the list.insert behaviour, None (and values larger than maximal index) will append (default behaviour), 0 will prepend, -1 will insert the item at the second to last position.

process(X_pred: scipy.sparse._csr.csr_matrix) scipy.sparse._csr.csr_matrix
Parameters

X_pred (csr_matrix) – csr_matrix containing recommended user-item pairs.

Returns

csr_matrix-object containing the filtered response.

Return type

csr_matrix

process_many(*X_preds: scipy.sparse._csr.csr_matrix) List[scipy.sparse._csr.csr_matrix]

Process all CSR Matrices passed as arguments.

Parameters

X_preds (csr_matrix) – The CSR matrices to process

Returns

A list of csr_matrix objects in the order the csr_matrices were passed in.

Return type

List[csr_matrix]