flurs.types.Item

class flurs.types.Item(index, feature=array([], dtype=float64))[source]

Item object for recommenders.

Parameters
  • index (int) – Item index used as their ID. Starting from 0.

  • features (numpy array, default=empty) – Feature vector associated with an item. An element can be price, category, date published, etc.

__init__(index, feature=array([], dtype=float64))[source]

Methods

__init__(index[, feature])

encode([dim, index, feature, vertical])

Encode an actor to an input vector for feature-based recommenders.

index_one_hot(dim)

Onehot-encode own index to a vector.

encode(dim=None, index=True, feature=True, vertical=False)[source]

Encode an actor to an input vector for feature-based recommenders.

Parameters
  • dim (int or None, default=None) – Number of dimensions for onehot-encoded index. Use self.index + 1 if None.

  • index (bool, default=True) – Include onehot-encoded index to an input vector.

  • feature (bool, default=True) – Include features associated with an actor.

  • vertical (bool, default=False) – Return as a transposed n-by-1 vertical vector.

Returns

n-dimensional vector representing an actor. Size can be (n, 1) or (1, n), depending on vertical parameter.

Return type

array

index_one_hot(dim)[source]

Onehot-encode own index to a vector.

Parameters

dim (int) – Number of dimensions of an output vector. Must be greater than or equal to self.index.

Returns

dim-dimensional onehot-encoded vector.

Return type

array