Algorithms
LocalOutlierFactor
The LocalOutlierFactor algorithm uses the scikit-learn Local Outlier Factor (LOF) to measure the local deviation of density of a given sample with respect to its neighbors. LocalOutlierFactor performs one-shot learning and is limited to…
The LocalOutlierFactor algorithm uses the scikit-learn Local Outlier Factor (LOF) to measure the local deviation of density of a given sample with respect to its neighbors. LocalOutlierFactor performs one-shot learning and is limited to fitting on training data and returning outliers. LocalOutlierFactor is an unsupervised outlier detection method. The anomaly score depends on how isolated the object is with respect to its neighbors.
For descriptions of the n_neighbors, leaf_size and other parameters, see the sci-kit learn documentation: http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.LocalOutlierFactor.html
Note: Using the LocalOutlierFactor algorithm requires running version 1.3 or above of the Python for Scientific Computing add-on.
Parameters
-
The
anomaly_scoreparameter default is True. Disable this default by adding theFalsekeyword to the command. -
The
n_neighborsparameter default is 20 -
The
leaf_sizeparameter default is 30 -
The
pparameter is limited top >=1 -
The
contaminationparameter must be within the range of 0.0 (not included) to 0.5 (included) -
The
contaminationparameter default is 0.1 -
Options for the
algorithmparameter include: brute, kd_tree, ball_tree, and auto. The default is auto. -
The brute, kd_tree, ball_tree, and auto
algorithmoptions have respective valid metrics. The defaultmetricfor each is minkowski.- Valid metrics for brute include: cityblock, euclidean, l1, l2, manhattan, chebyshev, minkowski, braycurtis, canberra, dice, hamming, jaccard, kulsinski, matching, rogerstanimoto, russellrao, sokalmichener, sokalsneath, cosine, correlation, sqeuclidean, and yule.
- Valid metrics for kd_tree include: cityblock, euclidean, l1, l2, manhattan, chebyshev, and minkowski.
- Valid metrics for ball_tree include: cityblock, euclidean, l1, l2, manhattan, chebyshev, minkowski, braycurtis, canberra, dice, hamming, jaccard, kulsinski, matching, rogerstanimoto, russellrao, sokalmichener, and sokalsneath.
-
The output for LocalOutlierFactor is a list of labels titled
is_outlier, assigned1for outliers, and-1for inliers
Syntax
fit LocalOutlierFactor <fields>
[n_neighbors=<int>] [leaf_size=<int>] [p=<int>]
[contamination=<float>]
[metric=<str>] [algorithm=<str>] [anomaly_score=<true|false>]
Syntax constraints
- You cannot save LocalOutlierFactor models using the
intokeyword. This algorithm does not support saving models and you cannot apply a saved model to new data. - LOF does not include the
predictmethod.
Example
The following example uses LocalOutlierFactor on a test set.
| inputlookup iris.csv | fit LocalOutlierFactor petal_length petal_width n_neighbors=10 algorithm=kd_tree metric=minkowski p=1 contamination=0.14 leaf_size=10
Local availability Permalink to this section
- Local class:
LocalOutlierFactor - Source file:
Splunk_ML_Toolkit/bin/algos/LocalOutlierFactor.py(in-repo pathSplunk_ML_Toolkit/bin/algos/LocalOutlierFactor.py) - algos.conf stanza:
[LocalOutlierFactor] - Class bases:
ClustererMixin,BaseAlgo
Source Permalink to this section
Adapted from the Splunk AI Toolkit 5.6.4 documentation at /en/splunk-cloud-platform/apply-machine-learning/use-ai-toolkit/5.6.4/algorithms-and-scoring-metrics-in-the-ai-toolkit/algorithms-in-the-ai-toolkit (section: anomaly).