reagent.preprocessing package

Submodules

reagent.preprocessing.batch_preprocessor module

reagent.preprocessing.identify_types module

reagent.preprocessing.identify_types.identify_type(values, enum_threshold=100)

reagent.preprocessing.normalization module

reagent.preprocessing.postprocessor module

reagent.preprocessing.preprocessor module

reagent.preprocessing.sparse_preprocessor module

class reagent.preprocessing.sparse_preprocessor.SparsePreprocessor(id2name: Dict[int, str], id2mapping: Dict[int, Dict[int, int]], device: torch.device)

Bases: torch.nn.Module

Performs preprocessing for sparse features (i.e. id_list, id_score_list)

Functionality includes: (1) changes keys from feature_id to feature_name, for better debuggability (2) maps sparse ids to embedding table indices based on id_mapping (3) filters out ids which aren’t in the id2name

preprocess_id_list(id_list: Dict[int, Tuple[torch.Tensor, torch.Tensor]]) → Dict[str, Tuple[torch.Tensor, torch.Tensor]]

Input: rlt.ServingIdListFeature Output: rlt.IdListFeature

preprocess_id_score_list(id_score_list: Dict[int, Tuple[torch.Tensor, torch.Tensor, torch.Tensor]]) → Dict[str, Tuple[torch.Tensor, torch.Tensor, torch.Tensor]]

Input: rlt.ServingIdScoreListFeature Output: rlt.IdScoreListFeature

reagent.preprocessing.sparse_preprocessor.make_sparse_preprocessor(feature_config: reagent.types.ModelFeatureConfig, device: torch.device)

Helper to initialize, for scripting SparsePreprocessor

reagent.preprocessing.sparse_preprocessor.map_id_list(raw_values: torch.Tensor, id2index: Dict[int, int]) → torch.Tensor
reagent.preprocessing.sparse_preprocessor.map_id_score_list(raw_keys: torch.Tensor, raw_values: torch.Tensor, id2index: Dict[int, int]) → Tuple[torch.Tensor, torch.Tensor]

reagent.preprocessing.sparse_to_dense module

reagent.preprocessing.transforms module

reagent.preprocessing.types module

class reagent.preprocessing.types.InputColumn

Bases: object

ACTION = 'action'
ACTION_PROBABILITY = 'action_probability'
CANDIDATE_FEATURES = 'candidate_features'
EXTRAS = 'extras'
ITEM_MASK = 'item_mask'
ITEM_PROBABILITY = 'item_probability'
MDP_ID = 'mdp_id'
METRICS = 'metrics'
NEXT_ACTION = 'next_action'
NEXT_CANDIDATE_FEATURES = 'next_candidate_features'
NEXT_ITEM_MASK = 'next_item_mask'
NEXT_ITEM_PROBABILITY = 'next_item_probability'
NEXT_STATE_FEATURES = 'next_state_features'
NEXT_STATE_ID_LIST_FEATURES = 'next_state_id_list_features'
NEXT_STATE_ID_SCORE_LIST_FEATURES = 'next_state_id_score_list_features'
NEXT_STATE_SEQUENCE_FEATURES = 'next_state_sequence_features'
NOT_TERMINAL = 'not_terminal'
POSITION_REWARD = 'position_reward'
POSSIBLE_ACTIONS = 'possible_actions'
POSSIBLE_ACTIONS_MASK = 'possible_actions_mask'
POSSIBLE_NEXT_ACTIONS = 'possible_next_actions'
POSSIBLE_NEXT_ACTIONS_MASK = 'possible_next_actions_mask'
REWARD = 'reward'
REWARD_MASK = 'reward_mask'
SEQUENCE_NUMBER = 'sequence_number'
SLATE_REWARD = 'slate_reward'
STATE_FEATURES = 'state_features'
STATE_ID_LIST_FEATURES = 'state_id_list_features'
STATE_ID_SCORE_LIST_FEATURES = 'state_id_score_list_features'
STATE_SEQUENCE_FEATURES = 'state_sequence_features'
STEP = 'step'
TIME_DIFF = 'time_diff'
TIME_SINCE_FIRST = 'time_since_first'

Module contents