Densify

class coba.environments.Densify

Ensure that features are dense.

Constructors

__init__(n_feats: int = 400, method: Literal['lookup', 'hashing'] = 'lookup', context: bool = True, action: bool = False)

Instantiate a Densify filter.

Parameters:
  • n_feats – The number of features densified environment should have.

  • method – How sparse features are turned into dense features. The hashing trick is more memory efficient but may have collisions. The lookup method is less memory efficient but guaranteed to have no collisions.

  • context – If True then contexts should be made sparse otherwise leave them alone.

  • action – If True then actions should be made sparse otherwise leave them alone.

  • Remarks – The “lookup” method produces a more efficient feature representation but its memory usage expand to the cardinality of the sparse features. The “hashing” method utilizes a less efficient feature representation but does not use any memory beyond the features. When using the ‘hashing’ method n_feats should be set to a large number such as 2**16.

Methods

filter(interactions: Iterable[Interaction]) Iterable[Interaction]

Apply filter to an Environment’s interactions.

Attributes

params