This task detects the samples that have a substantially lower density than its neighbors and labels the detections as anomalies.

For background on the algorithm used, see Local Outlier Factor Classification.

Example


; Start the application
e = ENVI()
 
; Open an input raster file
RasterFile = Filepath('qb_boulder_msi', Subdir=['data'], $
  Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(RasterFile)
 
; Get the Spectral Index task from the catalog of ENVITasks
SpectralTask=ENVITask('SpectralIndex')
 
; Define inputs
SpectralTask.INDEX = 'Normalized Difference Vegetation Index'
SpectralTask.INPUT_RASTER = Raster
 
; Run the task
SpectralTask.Execute
 
; Get the Image Threshold ROI task from the catalog of ENVITasks
ThresholdROITask=ENVITask('ImageThresholdToROI')
 
; Define inputs
ThresholdROITask.INPUT_RASTER = SpectralTask.OUTPUT_RASTER
ThresholdROITask.ROI_NAME = 'Water'
ThresholdROITask.ROI_COLOR = [0, 0, 255]
ThresholdROITask.THRESHOLD = [-1, -0.10000000149012, 0]
 
; Run the task
ThresholdROITask.Execute
 
; Get the statistics task from the catalog of ENVITasks
StatsTask = ENVITask('NormalizationStatistics')
 
; Define inputs
StatsTask.INPUT_RASTERS = Raster
 
; Run the task
StatsTask.Execute
 
; Get the data prep task from the catalog of ENVITasks
DataPrepTask = ENVITask('MLTrainingDataFromROIs')
 
; Define inputs
DataPrepTask.INPUT_RASTER = Raster
DataPrepTask.INPUT_ROI = ThresholdROITask.OUTPUT_ROI
DataPrepTask.BACKGROUND_LABELS = []
DataPrepTask.NORMALIZE_MIN_MAX = StatsTask.Normalization
DataPrepTask.Execute
 
; Get the training task from the catalog of ENVITasks
TrainTask = ENVITask('TrainLocalOutlierFactor')
 
; Define inputs
TrainTask.INPUT_RASTER = DataPrepTask.OUTPUT_RASTER
 
; Run the task
TrainTask.Execute
 
; Output model metadata
outputModelUri = TrainTask.OUTPUT_MODEL_URI
print, 'Model URI: ' + outputModelUri
 
outputModel = TrainTask.OUTPUT_MODEL
print, outputModel.Attributes

Syntax


Result = ENVITask('TrainLocalOutlierFactor')

Input properties (Set, Get): INPUT_RASTERS, LEAF_SIZE, MODEL_NAME, MODEL_DESCRIPTION, OUTPUT_MODEL_URI

Output properties (Get only): OUTPUT_MODEL

Properties marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Properties marked as "Get" are those whose values you can retrieve but not set.

Methods


This task inherits the following methods from ENVITask. See the ENVITask topic in ENVI Help.

  • AddParameter
  • Execute
  • Parameter
  • ParameterNames
  • RemoveParameters

Properties


This task inherits the following properties from ENVITask:

COMMUTE_ON_DOWNSAMPLE

COMMUTE_ON_SUBSET

DESCRIPTION

DISPLAY_NAME

NAME

REVISION

See the ENVITask topic in ENVI Help for details.

This task also contains the following properties:

INPUT_RASTERS (required)

Specify one or more preprocessed training rasters to be used for training.

LEAF_SIZE (optional)

Specify the leaf size. Changing the leaf size can affect the speed of construction and query, as well as the memory required to store the tree. The optimal value depends on the nature of the problem. The default is 30.

MODEL_NAME (optional)

Specify the name of the model. The default is Local Outlier Factor Anomaly Detector.

MODEL_DESCRIPTION (optional)

Specify the purpose of the model.

OUTPUT_MODEL (required)

This is a reference to the output model file.

OUTPUT_MODEL_URI (optional)

Specify a string with the fully qualified filename and path of the associated OUTPUT_MODEL. If you do not specify this property, or set it to an exclamation symbol (!), a temporary file will be created.

Version History


Deep Learning 2.0

Introduced

See Also


ENVI Machine Learning Algorithms Background, TrainExtraTrees Task, TrainIsolationForest Task, TrainKNeighbors Task, TrainLinearSVM Task, TrainNaiveBayes Task, TrainRandomForest Task, TrainRBFSVM Task