language: cn
model_unique_abbr: knn_sklearn
version: 1.0.0
identification:
  docker_image_name: knn:1.0.0-sklearn1.0.2
  model_name: k近邻分类器（点数据-CSV）
  semantic: K-Nearest Neighbor
  description: 通过某种距离度量找出训练集中与其特征空间中最邻近最靠近的k个训练样本，然后基于这k个邻居的信息进行预测
  category_application: 预测型
  category_data:
  - 结构化事务数据
  keywords:
  - 监督分类
parameter_info:
  parameters:
  - arg_name: td
    param_type: input_data
    name: 训练样本
    description: 模型训练所需的样本数据，第一行为表头
    data_type: csv
    data_semantic: training data

  - arg_name: tl
    param_type: input_data
    name: 训练标签
    description: 模型训练所需的标签数据，第一行为表头
    data_type: csv
    data_semantic: training label

  - arg_name: fd
    param_type: input_data
    name: 预测数据
    description: 待预测数据，第一行为表头
    data_type: csv
    data_semantic: forecast data

  - arg_name: op
    param_type: output_data
    name: 输出路径
    description: 预测结果的输出路径，输出文件格式为csv
    data_type: csv
    data_semantic: output path

  - arg_name: nn
    param_type: param
    name: 近邻数
    description: 用于kneighbors查询的近邻数，默认值为5
    data_type: int
    data_semantic: n_neighbors
    specification:
      default: 5

  - arg_name: w
    param_type: param
    name: 权重函数
    description: 预测中使用的权重函数
    is_required: false
    data_type: enum
    data_semantic: weights
    specification:
      default: uniform
      enum:
      - uniform
      - distance

  - arg_name: a
    param_type: param
    name: 最近邻函数
    description: 计算最近邻点的算法
    is_required: false
    data_type: enum
    data_semantic: algorithm
    specification:
      default: auto
      enum:
      - auto
      - ball_tree
      - kd_tree
      - brute

  - arg_name: ls
    param_type: param
    name: 叶大小
    description: 影响构造和查询速度，以及存储树所需的内存，取值范围为[1,10000]，默认值为30
    is_required: false
    data_type: int
    data_semantic: leaf size
    specification:
      default: 30
      range:
      - "[1,10000]"

  - arg_name: p
    param_type: param
    name: 功率参数
    description: Minkowski指标的功率参数，取值范围为[0,2]，默认值为2
    is_required: false
    data_type: int
    data_semantic: power
    specification:
      default: 2
      range:
      - "[0,2]"

  - arg_name: m
    param_type: param
    name: 距离度量
    description: 树使用的距离度量
    data_type: enum
    data_semantic: distance metric
    specification:
      default: minkowski
      enum:
      - euclidean
      - manhattan
      - chebyshev
      - wminkowski
      - minkowski
      - seuclidean
      - mahalanobis


  - arg_name: nj
    param_type: param
    visible: false
    name: 并行工作数
    description: 为近邻点搜索运行的并行作业数，取值范围为[-2,]，默认值为-1
    is_required: false
    data_type: int
    data_semantic: n_jobs
    specification:
      default: -1
      range:
      - "[-2,]"

  - arg_name: ts
    param_type: param
    name: 测试集占比
    description: 测试集在整个数据集中的占比，取值范围为(0.0,1.0]，默认值为0.3
    is_required: false
    data_type: float
    data_semantic: test_size
    specification:
      default: 0.3
      range:
      - "(0,1]"
application:
  domain: 结构化事务数据分类
  objective: 给定先验信息，在特征空间中根据某种距离度量找出训练集中与其最靠近的k个训练样本，基于这些样本信息进行类别预测
  mechanism: 在定类决策上依据最邻近的k个样本的类别来决定待分样本所属的类别
operation:
  usage: 须指定训练数据、训练标签、待预测的数据及输出路径，其他参数均可默认
  exec_example:
    - docker run -v $(pwd):/data knn:1.0.0-sklearn1.0.2 -td /data/test_knc_data.csv -tl /data/test_knc_label.csv -fd /data/test_knc_pre.csv -op result.csv
  license:
  - BSD-3-Clause
  - PSF-2.0
  - GPL-2.0
  tips: 导入数据第一行为表头，会忽略读取。
technique:
  language:
  - python
  os:
  - windows
  - linux
  parallel:
  - multithreading
  hardware:
  - cpu
  dependencies:
  - name: scikit-learn
    version: 1.0.2
  - name: pandas
    version: 1.1.3
  - name: numpy
    version: 1.19.2
source:
  maintainer: Xian Cao
  organization: Beijing University of Civil Engineering and Architecture
  contact: southerndog@foxmail.com
  integrated_softwares:
  - name: scikit-learn
    version: 1.0.2
    license: BSD-3-Clause
  references:
  - Duda, R. O., Hart, P. E. 1973. Pattern classification and scene analysis. New York:Wiley, 3:731–739.
  - https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html
