This task executes the Isolation Forest anomaly detection algorithm against the provided input training rasters. The IsolationForest task isolates detections by randomly selecting a feature, then randomly selecting a split value between the maximum and minimum values of the selected feature.
For background on the algorithm used, see Isolation Forest Classification.
Example
e = ENVI()
RasterFile = Filepath('qb_boulder_msi', Subdir=['data'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(RasterFile)
SpectralTask=ENVITask('SpectralIndex')
SpectralTask.INDEX = 'Normalized Difference Vegetation Index'
SpectralTask.INPUT_RASTER = Raster
SpectralTask.Execute
ThresholdROITask=ENVITask('ImageThresholdToROI')
ThresholdROITask.INPUT_RASTER = SpectralTask.OUTPUT_RASTER
ThresholdROITask.ROI_NAME = 'Water'
ThresholdROITask.ROI_COLOR = [0, 0, 255]
ThresholdROITask.THRESHOLD = [-1, -0.10000000149012, 0]
ThresholdROITask.Execute
StatsTask = ENVITask('NormalizationStatistics')
StatsTask.INPUT_RASTERS = Raster
StatsTask.Execute
DataPrepTask = ENVITask('MLTrainingDataFromROIs')
DataPrepTask.INPUT_RASTER = Raster
DataPrepTask.INPUT_ROI = ThresholdROITask.OUTPUT_ROI
DataPrepTask.BACKGROUND_LABELS = []
DataPrepTask.NORMALIZE_MIN_MAX = StatsTask.Normalization
DataPrepTask.Execute
TrainTask = ENVITask('TrainIsolationForest')
TrainTask.INPUT_RASTER = DataPrepTask.OUTPUT_RASTER
TrainTask.NUM_ESTIMATORS = 100
TrainTask.Execute
outputModelUri = TrainTask.OUTPUT_MODEL_URI
print, 'Model URI: ' + outputModelUri
outputModel = TrainTask.OUTPUT_MODEL
print, outputModel.Attributes
Syntax
Result = ENVITask('TrainIsolationForest')
Input parameters (Set, Get): BALANCE_CLASSES, INPUT_RASTERS, MODEL_DESCRIPTION, MODEL_NAME, MODEL_VERSION, NUM_ESTIMATORS, OUTPUT_MODEL_URI
Output parameters (Get only): OUTPUT_MODEL
Parameters marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Parameters marked as "Get" are those whose values you can retrieve but not set.
Input Parameters
BALANCE_CLASSES (optional)
Specify whether all classes should be considered equal during training. This helps to account for classes with few samples compared to classes with many samples.
INPUT_RASTERS (required)
Specify one or more preprocessed training rasters to be used for training.
MODEL_DESCRIPTION (optional)
Specify the purpose of the model.
MODEL_NAME (optional)
Specify the name of the model. The default is Isolation Forest Anomaly Detector.
MODEL_VERSION (optional)
Specify a semantic version format (MAJOR.MINOR.PATCH) for the trained model (for example, 1.0.0). The version may indicate the following:
- MAJOR: Breaking changes to the model
- MINOR: Compatibility or new features
- PATCH: Minor adjustments
NUM_ESTIMATORS (optional)
Specify the number of decision trees to use. The estimators are the predictors of the algorithm. The default is 100.
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 parameter, or set it to an exclamation symbol (!), a temporary file will be created.
Output Parameters
OUTPUT_MODEL
This is a reference to the output model file.
Methods
Execute
Parameter
ParameterNames
See ENVI Help for details on these ENVITask methods.
Properties
DESCRIPTION
DISPLAY_NAME
NAME
REVISION
See the ENVITask topic in ENVI Help for details.
Version History
Machine Learning 2.0
|
Introduced |
Machine Learning 6.2
|
Added the MODEL_VERSION and OUTPUT_MODEL_URI parameters
|
See Also
ENVI Machine Learning Algorithms Background, TrainBirch Task, TrainExtraTrees Task, TrainKNeighbors Task, TrainLinearSVM Task, TrainLocalOutlierFactor Task, TrainMiniBatchKMeans Task, TrainNaiveBayes Task, TrainRandomForest Task, TrainRBFSVM Task