RMTPP documentation
this neural network model is based on the paper
"Recurrent Marked Temporal Point Processes: Embedding Event History to Vector" by
Du, et al.
In particular, the implementation is a modified version from the repository
https://github.com/woshiyyya/ERPP-RMTPP.git
.
Net
Bases: Module
Source code in server/RMTPP_torch/model.py
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 40 41 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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
RMTPPLoss(pred, gold)
calculate the loss for the time.
Source code in server/RMTPP_torch/model.py
52 53 54 55 56 57 58 59 |
|
predict(batch, pm_active=False)
Make a prediction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch |
tuple
|
A batch containing one or more inputs for doing predictions. |
required |
pm_active |
bool
|
If True, returns only the most likely prediction. |
False
|
Returns:
Type | Description |
---|---|
tuple or int: If pm_active is True, returns a tuple containing the index (encoded marker) of the event that has the highest probability, the maximum probability, and the last time prediction. If pm_active is False, returns two lists. The first list contains the timestamps of the predictions, and the second list contains the index (encoded marker) of the event that has the highest probability. |
Source code in server/RMTPP_torch/model.py
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 137 138 |
|
predict_sorted(batch)
Make a prediction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch |
tuple
|
A batch containing one or more inputs for doing predictions. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing two lists. The first list contains the timestamps of the predictions, and the second list contains tuples of the form |
Source code in server/RMTPP_torch/model.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
this module computes the input for the RNN. It is assumed that the input event log is in the right format, i.e. rows are sorted by case id and timestamp, and the columns are encoded properly.
It computes time differences and uses a sliding window.
ATMDataset
helper class for the neural network that is in charge of doing the sliding window algorithm over the sequences and get the time differences in the timestamp column of the data.
it can be seen as a wrapper that does some further preprocessing that is very especific to the NN.
Source code in server/RMTPP_torch/util.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 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 |
|
generate_sequence()
use the sliding window algorithm so that the sequences fit in the NN (this way we fit the proper tensor dimension) .
Source code in server/RMTPP_torch/util.py
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 |
|
importance_weight(count)
used for CrossEntropyLoss
Source code in server/RMTPP_torch/util.py
125 126 127 128 129 130 |
|
to_features(batch)
staticmethod
Returns:
Type | Description |
---|---|
Two tensors: one containing the time differences between adjacent time stamps |
|
and the other one containing the events. |
Source code in server/RMTPP_torch/util.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
clf_metric(pred, gold, n_class)
compute test metrics. :return: - recall - precision - f1 score
Source code in server/RMTPP_torch/util.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|