Outliers
Outliers
BeyondQuartileOutlierRemover
Bases: TransformerStep
Remove values outside (Q1, Q3)
If clip is True the values will be clipped between the range, otherwise the values are going to be replaced by inf and -inf
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lower_quantile |
float
|
Lower quantile threshold for the non-anomalous values, by default 0.25 |
0.25
|
upper_quantile |
float
|
Upper quantile threshold for the non-anomalous values, by default 0.75 |
0.75
|
clip |
bool
|
Wether to clip the values outside the range, by default False |
False
|
name |
Optional[str]
|
Name of the step, by default None |
None
|
Source code in ceruleo/transformation/features/outliers.py
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 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 231 232 233 234 235 236 237 238 |
|
fit(X)
Compute the quantiles of the data
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Source code in ceruleo/transformation/features/outliers.py
partial_fit(X)
Compute the quantiles of the data incrementally
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Source code in ceruleo/transformation/features/outliers.py
transform(X)
Remove the outliers from the input life.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new DataFrame with the outliers removed |
Source code in ceruleo/transformation/features/outliers.py
EWMAOutOfRange
Bases: TransformerStep
Compute the EWMA limits and mark as NaN points outside UCL and LCL
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lambda_ |
float
|
Parameter for the EWMA, by default 0.5 |
0.5
|
return_mask |
bool
|
Wether to return a mask with the outliers or the original data with the outliers marked as NaN, by default False |
False
|
name |
Optional[str]
|
Name of the step, by default None |
None
|
Source code in ceruleo/transformation/features/outliers.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
|
fit(X, y=None)
Compute the EWMA limits
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Source code in ceruleo/transformation/features/outliers.py
partial_fit(X, y=None)
Compute the EWMA limits incrementally
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Source code in ceruleo/transformation/features/outliers.py
transform(X)
Remove the outliers from the input life.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new DataFrame with the outliers removed |
Source code in ceruleo/transformation/features/outliers.py
IQROutlierRemover
Bases: TransformerStep
Remove values outside (Q1 - marginIQR, Q2 + marginIQR)
If clip is True the values will be clipped between the range, otherwise the values are going to be replaced by inf and -inf
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lower_quantile |
float
|
Lower quantile threshold for the non-anomalous values, by feault 0.25 |
0.25
|
upper_quantile |
float
|
Upper quantile threshold for the non-anomalous values, by feault 0.75 |
0.75
|
margin |
float
|
How many times the IQR gets multiplied, by default 0.75 |
1.5
|
proportion_to_sample |
float
|
If you want to compute the quantiles in an smaller proportion of data you can specify it,by default 1.0 |
1.0
|
clip |
bool
|
Wether to clip the values outside the range, by default False |
False
|
name |
Optional[str]
|
Name of the step, by default None |
None
|
Source code in ceruleo/transformation/features/outliers.py
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 |
|
fit(X)
Compute the quantiles of the data and the interquartile range incrementally
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Source code in ceruleo/transformation/features/outliers.py
partial_fit(X)
Compute the quantiles of the data and the interquartile range incrementally
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Source code in ceruleo/transformation/features/outliers.py
transform(X)
Remove the outliers from the input life.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new DataFrame with the outliers removed |
Source code in ceruleo/transformation/features/outliers.py
IsolationForestOutlierRemover
Bases: TransformerStep
Remove outliers using Isolation Forests to detect them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_estimators |
Number of trees in the forest, by default 100 |
100
|
|
name |
Name of the step, by default None |
required |
Source code in ceruleo/transformation/features/outliers.py
fit(X)
Fit the Isolation Forest model to the data
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Source code in ceruleo/transformation/features/outliers.py
transform(X)
Remove the outliers from the input life.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new DataFrame with the outliers removed |
Source code in ceruleo/transformation/features/outliers.py
RollingMeanOutlierRemover
Bases: TransformerStep
Compute the rolling mean and use it to compute the upper and lower bound to define outliers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
window |
int
|
Window for the rolling mean, by default 15 |
15
|
lambda_ |
float
|
Multiplier of the std used to define the bounds, by default 3 |
3
|
return_mask |
bool
|
Wether to return a mask with the outliers or the original data with the outliers marked as NaN, by default False |
False
|
name |
Optional[str]
|
Name of the step, by default None |
None
|
Source code in ceruleo/transformation/features/outliers.py
transform(X)
Remove the outliers from the input life.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new DataFrame with the outliers removed |
Source code in ceruleo/transformation/features/outliers.py
ZScoreOutlierRemover
Bases: TransformerStep
Remove values outside (mean - number_of_std_allowedstd, mean + number_of_std_allowedstd). The outliers are set to NaN
Parameters:
Name | Type | Description | Default |
---|---|---|---|
number_of_std_allowed |
Number of standard deviations to consider a point an outlier |
required | |
name |
str
|
Name of the step, by default None |
None
|
Source code in ceruleo/transformation/features/outliers.py
fit(X)
Fit a StandardScaler to the data
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
transform(X)
Remove the outliers from the input life.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
Input life |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
A new DataFrame with the outliers removed |