language: cn
model_unique_abbr: knn_sagagis
version: 1.0
identification:
  docker_image_name: sagagis:debian-8.5.0
  docker_run_prefix:
    - imagery_opencv
    - 6
  model_name: k近邻分类器（栅格-TIF）
  semantic: K-Nearest Neighbor
  description: 通过某种距离度量找出训练集中与其特征空间中最邻近最靠近的k个训练样本，然后基于这k个邻居的信息进行预测。
  category_application: 预测型
  category_data:
  - 遥感影像数据
  - 图像数据
  keywords:
  - 监督分类
parameter_info:
  parameters:
  - arg_name: FEATURES
    param_type: input_data
    name: 要素栅格文件
    description: 待分类的栅格文件
    data_type: tif
    data_semantic: Feature raster file

  - arg_name: NORMALIZE
    param_type: param
    name: 归一化
    description: 是否将输入数据进行归一化处理
    is_required: false
    data_type: enum
    data_semantic: Normalize
    specification:
      default: "False"
      enum:
      - "True"
      - "False"

  - arg_name: CLASSES
    param_type: output_data
    name: 分类结果
    description: 输出分类结果的栅格文件，输出文件格式为tif
    data_type: tif
    data_semantic: Classification

  - arg_name: CLASSES_LUT
    param_type: output_data
    name: 分类查找表
    description: 根据训练区数据获得的分类查找表，输出文件格式为csv
    is_required: false
    data_type: csv
    data_semantic: Look-up Table

  - arg_name: TRAIN_AREAS
    param_type: input_data
    name: 训练区
    description: 用于模型训练的矢量数据
    data_type: shp
    data_semantic: Training Areas

  - arg_name: TRAIN_CLASS
    param_type: param
    name: 训练区分类标签
    description: 训练区矢量文件的字段，用于标记类别
    data_type: str
    data_semantic: Class Identifier

  - arg_name: TRAIN_BUFFER
    param_type: param
    name: 训练区缓冲区大小
    description: 为非多边形训练区创建一个缓冲区，取值范围为(0.0,)，默认值为1.0
    is_required: false
    data_type: float
    data_semantic: Arc Vertex Distance
    specification:
      default: 1.0
      range:
      - (0.0,)

  - arg_name: NEIGHBOURS
    param_type: param
    name: 默认邻近数
    description: 默认邻近数，最小为1，默认值为3
    is_required: false
    data_type: int
    data_semantic: Default Number of Neighbours
    specification:
      default: 3
      range:
      - "[1,)"

  - arg_name: TRAINING
    param_type: param
    name: 训练方式
    description: 训练方式，“0”代表分类模型，“1”代表回归模型
    is_required: false
    data_type: enum
    data_semantic: Training Method
    specification:
      default: 0
      enum:
      - 0
      - 1

  - arg_name: ALGORITHM
    param_type: param
    name: 算法类型
    description: 算法类型，“0”代表“brute force”，“1”代表“KD Tree”
    is_required: false
    data_type: enum
    data_semantic: Algorithm Type
    specification:
      default: 0
      enum:
      - 0
      - 1

  - arg_name: EMAX
    param_type: param
    name: KD树实现参数
    description: KD树实现参数，取值范围为[1,)，默认为1000
    is_required: false
    data_type: int
    data_semantic: Parameter for KD Tree implementation
    param_switches:
    - switch_arg_name: ALGORITHM
      switch_arg_value_regex: 1$
      switch_arg_value_examples: [1]
    specification:
      default: 1000
      range:
      - "[1,)"
  groups:
  - group_id: kdparameter
    group_name: kd树参数
    group_param_arg_names:
    - ALGORITHM
    - EMAX
application:
  domain: 格网数据分类
  objective: 给定先验信息，在特征空间中根据某种距离度量找出训练集中与其最靠近的k个训练样本，基于这些样本信息进行类别预测
  mechanism: 在定类决策上依据最邻近的k个样本的类别来决定待分样本所属的类别
operation:
  usage: 该算法须指定训练区、训练标签字段、待预测的数据及输出路径，其他参数均可默认
  exec_example:
  - docker run -v $(pwd):/data sagagis:debian-8.5.0 imagery_opencv 6 [-FEATURES <str>] [-NORMALIZE <str>] [-CLASSES <str>] [-CLASSES_LUT <str>] [-TRAIN_AREAS <str>] [-TRAIN_CLASS <str>] [-TRAIN_BUFFER <double>] [-NEIGHBOURS <num>] [-TRAINING <str>] [-ALGORITHM <str>] [-EMAX <num>]
  license:
  - SAGA-GIS-GNU General Public
technique:
  language:
  - Python
  os:
  - Linux
  - Windows
  dependencies:
  - name: SAGA-GIS
    version: 8.5.0
source:
  maintainer: Shan Huang
  organization: Beijing University of Civil Engineering and Architecture
  contact: huangshan3mt@foxmail.com
  integrated_softwares:
  - name: SAGA-GIS
    version: 8.5.0
    license: GNU General Public
  references:
  - Duda, R. O., Hart, P. E. 1973. Pattern classification and scene analysis. New York:Wiley, 3:731–739.
  - https://saga-gis.sourceforge.io/saga_tool_doc/8.1.0/imagery_opencv_6.html
