processor
Processor ¶
Bases: ABC
Base class for processing data.
Abstract class for processing data. Subclasses should implement the process method to handle specific data processing logic.
Source code in src/recnexteval/settings/processor.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
process(past_interaction, future_interaction) abstractmethod ¶
Injects the user ID to indicate ID for prediction.
User ID to be predicted by the model will be indicated with item ID of "-1" as the corresponding label. The matrix with past interactions will contain the user ID to be predicted which will be derived from the set of user IDs in the future interaction matrix. Timestamp of the masked interactions will be preserved as the item ID are simply masked with "-1".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
past_interaction | InteractionMatrix | Matrix of past interactions. | required |
future_interaction | InteractionMatrix | Matrix of future interactions. | required |
Returns:
| Type | Description |
|---|---|
tuple[InteractionMatrix, InteractionMatrix] | Tuple of past interaction with injected user ID to predict and ground truth future interactions of the actual interaction. |
Source code in src/recnexteval/settings/processor.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
PredictionDataProcessor ¶
Bases: Processor
Injects the user ID to indicate ID for prediction.
Operates on the past and future interaction matrices to inject the user ID to be predicted by the model into the past interaction matrix. The resulting past interaction matrix will contain the user ID to be predicted which will be derived from the set of user IDs in the future interaction matrix. Timestamp of the masked interactions will be preserved as the item ID are simply masked with "-1".
The corresponding ground truth future interactions of the actual interaction will be returned as well in a tuple when process is called.
Source code in src/recnexteval/settings/processor.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
process(past_interaction, future_interaction, top_K=1) ¶
Processes past and future interactions to prepare data for prediction.
Injects user IDs for prediction into the past interaction matrix based on future interactions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
past_interaction | InteractionMatrix | Matrix of past interactions. | required |
future_interaction | InteractionMatrix | Matrix of future interactions. | required |
top_K | int | Number of top interactions to consider. Defaults to 1. | 1 |
Returns:
| Type | Description |
|---|---|
tuple[InteractionMatrix, InteractionMatrix] | Tuple of processed past interaction and ground truth. |
Source code in src/recnexteval/settings/processor.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |