This task implements learning based on the k nearest neighbors of each query point, where k is an integer value specified by the user in the form of ROI class values.
For background on the algorithm used, see K-Neighbors Classification.
Example
e = ENVI()
RasterFile = Filepath('qb_boulder_msi', Subdir=['data'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(RasterFile)
ROIFile = Filepath('qb_boulder_roi.xml', Subdir=['data'], $
Root_Dir=e.Root_Dir)
ROI = e.OpenROI(ROIFile)
StatsTask = ENVITask('NormalizationStatistics')
StatsTask.INPUT_RASTERS = Raster
StatsTask.Execute
DataPrepTask = ENVITask('MLTrainingDataFromROIs')
DataPrepTask.INPUT_RASTER = Raster
DataPrepTask.INPUT_ROI = ROI
DataPrepTask.BACKGROUND_LABELS = ['Disturbed Earth', 'Water']
DataPrepTask.NORMALIZE_MIN_MAX = StatsTask.Normalization
DataPrepTask.Execute
TrainTask = ENVITask('TrainKNeighbors')
TrainTask.INPUT_RASTER = DataPrepTask.OUTPUT_RASTER
TrainTask.Execute
outputModelUri = TrainTask.OUTPUT_MODEL_URI
print, 'Model URI: ' + outputModelUri
outputModel = TrainTask.OUTPUT_MODEL
print, outputModel.Attributes, /IMPLIED
Syntax
Result = ENVITask('TrainKNeighbors')
Input properties (Set, Get): INPUT_RASTERS, 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.
MODEL_NAME (optional)
Specify the name of the model. The default is K-Neighbors Supervised Classifier.
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, TrainBirch Task, TrainExtraTrees Task, TrainIsolationForest Task, TrainLinearSVM Task, TrainLocalOutlierFactor Task, TrainMiniBatchKMeans Task, TrainNaiveBayes Task, TrainRandomForest Task, TrainRBFSVM Task