IKGAD
ikpykit.group.IKGAD ¶
IKGAD(
n_estimators_1=200,
max_samples_1="auto",
n_estimators_2=200,
max_samples_2="auto",
method="inne",
contamination="auto",
random_state=None,
)
Bases: OutlierMixin
, BaseEstimator
Isolation Kernel-based Group Anomaly Detection.
IKGAD applies isolation kernel techniques to detect anomalies in groups of data points. It leverages a two-step approach: first transforming the data using an isolation kernel, then calculating kernel mean embeddings for each group to detect anomalous groups. The algorithm is effective for detecting both global and local group anomalies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_estimators_1 |
int
|
The number of base estimators in the first-level ensemble. |
200
|
max_samples_1 |
int, float, or "auto"
|
The number of samples to draw for training each first-level base estimator:
|
"auto"
|
n_estimators_2 |
int
|
The number of base estimators in the second-level ensemble. |
200
|
max_samples_2 |
int, float, or "auto"
|
The number of samples to draw for training each second-level base estimator:
|
"auto"
|
method |
(inne, anne, auto)
|
Isolation method to use. The "inne" option corresponds to the approach described in the original paper. |
"inne"
|
contamination |
auto or float
|
Proportion of outliers in the data set:
|
"auto"
|
random_state |
int, RandomState instance or None
|
Controls the random seed for reproducibility. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
iso_kernel_1_ |
IsoKernel
|
First-level trained isolation kernel. |
offset_ |
float
|
Decision threshold for outlier detection. |
References
.. [1] Kai Ming Ting, Bi-Cun Xu, Washio Takashi, Zhi-Hua Zhou (2022). Isolation Distributional Kernel: A new tool for kernel based point and group anomaly detections. IEEE Transactions on Knowledge and Data Engineering.
Examples:
>>> from ikpykit.group import IKGAD
>>> import numpy as np
>>> X =[[[1.0, 1.1], [1.2, 1.3]], [[1.3, 1.2], [1.1, 1.0]], [[1.0, 1.2], [1.4, 1.3]], [[5.0, 5.1], [5.2, 5.3]]]
>>> clf = IKGAD(max_samples_1=2, max_samples_2=2, contamination=0.25, random_state=42)
>>> clf = clf.fit(X)
>>> clf.predict(X)
array([ 1, 1, 1, -1])
Source code in ikpykit/group/anomaly/_ikgad.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
fit ¶
fit(X)
Fit the IKGAD model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
array-like of shape (n_groups, n_samples, n_features)
|
The input data, where n_groups is the number of groups, n_samples is the number of instances per group, and n_features is the number of features. |
required |
Returns:
Name | Type | Description |
---|---|---|
self |
object
|
Fitted estimator. |
Notes
Sets the is_fitted_
attribute to True
.
Source code in ikpykit/group/anomaly/_ikgad.py
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 |
|
predict ¶
predict(X)
Predict if groups are outliers or inliers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
array-like of shape (n_groups, n_samples, n_features)
|
The input groups to evaluate |
required |
Returns:
Name | Type | Description |
---|---|---|
is_inlier |
ndarray of shape (n_groups,)
|
For each group, returns whether it is an inlier (+1) or outlier (-1) according to the fitted model. |
Source code in ikpykit/group/anomaly/_ikgad.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
decision_function ¶
decision_function(X)
Compute decision scores for groups.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
array-like of shape (n_groups, n_samples, n_features)
|
The input groups to evaluate |
required |
Returns:
Name | Type | Description |
---|---|---|
scores |
ndarray of shape (n_groups,)
|
Decision scores. Negative scores represent outliers, positive scores represent inliers. |
Source code in ikpykit/group/anomaly/_ikgad.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
score_samples ¶
score_samples(X)
Compute anomaly scores for groups.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
array-like of shape (n_groups, n_samples, n_features)
|
The input groups to evaluate |
required |
Returns:
Name | Type | Description |
---|---|---|
scores |
ndarray of shape (n_groups,)
|
Anomaly scores where lower values indicate more anomalous groups. |
Source code in ikpykit/group/anomaly/_ikgad.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|