Data transformations
transforms.ClipAndScalePPI
Bases: Module
Transform class for scaling of per-packet information (PPI) sequences. This transform clips packet sizes and inter-packet times and scales them using a specified scaler.
This class inherits from nn.Module
, and the data transformation is implemented in the forward
method.
When used with the cesnet-datazoo
package, the transform will be fitted during dataset initialization. Otherwise, the psizes_scaler_attrs
and ipt_scaler_attrs
must be provided.
The required entries in psizes_scaler_attrs
and ipt_scaler_attrs
depend on the scaler used.
- For
StandardScaler
, the required attributes aremean_
andscale_
. - For
RobustScaler
, the required attributes arecenter_
andscale_
. - For
MinMaxScaler
, the required attributesmin_
andscale_
.
Expected format of input PPI sequences: (batch_size, ppi_length, ppi_channels)
Info
The zero padding in PPI sequences is preserved during scaling, i.e., the padding zeroes are kept in the output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
psizes_scaler_enum |
ScalerEnum | str
|
What scaler should be used for packet sizes. Options are standard, robust, minmax, and no-scaling. |
STANDARD
|
ipt_scaler_enum |
ScalerEnum | str
|
What scaler should be used for inter-packet times. Options are standard, robust, minmax, and no-scaling. |
STANDARD
|
pszies_min |
int
|
Clip packet sizes to this minimum value. |
1
|
psizes_max |
int
|
Clip packet sizes to this maximum value. |
1500
|
ipt_min |
int
|
Clip inter-packet times to this minimum value. |
0
|
ipt_max |
int
|
Clip inter-packet times to this maximum value. |
65000
|
psizes_scaler_attrs |
Optional[dict[str, list[float]]]
|
To use a pre-fitted packet sizes scaler, provide its attributes here. |
None
|
ipt_scaler_attrs |
Optional[dict[str, list[float]]]
|
To use a pre-fitted inter-packet times scaler, provide its attributes here. |
None
|
Source code in cesnet_models\transforms.py
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 |
|
transforms.ClipAndScaleFlowstats
Bases: Module
Transform class for scaling of features describing an entire network flow -- called flow statistics. This transform clips flow statistics to their quantile_clip
quantile and scales them using a specified scaler.
This class inherits from nn.Module
, and the data transformation is implemented in the forward
method.
When used with the cesnet-datazoo
package, the transform will be fitted during dataset initialization. Otherwise, the flowstats_scaler_attrs
must be provided.
The required entries in flowstats_scaler_attrs
depend on the scaler used.
- For
StandardScaler
, the required attributes aremean_
andscale_
. - For
RobustScaler
, the required attributes arecenter_
andscale_
. - For
MinMaxScaler
, the required attributesmin_
andscale_
.
Expected format of input flow statistics: (batch_size, flowstats_features)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flowstats_scaler_enum |
ScalerEnum | str
|
What scaler should be used for flow statistics. Options are standard, robust, and minmax. |
ROBUST
|
quantile_clip |
float
|
Clip flow statistics to this quantile. |
0.99
|
flowstats_quantiles |
Optional[list[float]]
|
To use pre-fitted quantiles, provide them here. |
None
|
flowstats_scaler_attrs |
Optional[dict[str, list[float]]]
|
To use a pre-fitted scaler, provide its attributes here. |
None
|
Source code in cesnet_models\transforms.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
transforms.NormalizeHistograms
Bases: Module
Transform class for normalizing packet histograms.
This class inherits from nn.Module
, and the data transformation is implemented in the forward
method.
Expected format of input packet histograms: (batch_size, 4 * PHIST_BIN_COUNT)
.
The input histograms are expected to be in the following order: source packet sizes, destination packet sizes, source inter-packet times, and destination inter-packet times.
Each of the four histograms is expected to have PHIST_BIN_COUNT
bins, which is 8 in the current implementation.
Source code in cesnet_models\transforms.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
Enums for configuration
The following enums are used for the configuration of transformations.
transforms.ScalerEnum
Available scalers for flow statistics, packet sizes, and inter-packet times.
class-attribute
instance-attribute
STANDARD = 'standard'
Standardize features by removing the mean and scaling to unit variance - StandardScaler
.
class-attribute
instance-attribute
ROBUST = 'robust'
Robust scaling with the median and the interquartile range - RobustScaler
.
class-attribute
instance-attribute
MINMAX = 'minmax'
Scaling to a (0, 1) range - MinMaxScaler
.