TransformedSet#

class libreco.data.TransformedSet(user_indices=None, item_indices=None, labels=None, sparse_indices=None, dense_values=None)[source]#

Dataset after transforming.

Often generated by calling functions in DatasetPure or DatasetFeat, then TransformedSet will be used in formal training.

Parameters:
  • user_indices (numpy.ndarray) – All user rows in data, represented in inner id.

  • item_indices (numpy.ndarray) – All item rows in data, represented in inner id.

  • labels (numpy.ndarray) – All labels in data.

  • sparse_indices (numpy.ndarray or None, default: None) – All sparse rows in data, represented in inner id.

  • dense_values (numpy.ndarray or None, default: None) – All dense rows in data.

property user_indices#

All user rows in data

property item_indices#

All item rows in data

property sparse_indices#

All sparse rows in data

property dense_values#

All dense rows in data

property labels#

All labels in data

property sparse_interaction#

User-item interaction data, in scipy.sparse.csr_matrix format.

class libreco.data.TransformedEvalSet(user_indices, item_indices, labels)[source]#

Dataset after transforming.

Often generated by calling functions in DatasetPure or DatasetFeat, then TransformedEvalSet will be used in evaluation and testing.

Parameters:
  • user_indices (numpy.ndarray) – All user rows in data, represented in inner id.

  • item_indices (numpy.ndarray) – All item rows in data, represented in inner id.

  • labels (numpy.ndarray) – All labels in data.

build_negatives(n_items, num_neg, seed)[source]#

Perform negative sampling on all the data contained.

Parameters:
  • n_items (int) – Number of total items.

  • num_neg (int) – Number of negative samples for each positive sample.

  • seed (int) – Random seed.