VectorClassifier

根据模型文件对输入矢量数据进行分类。

描述

此应用程序基于由 TrainVectorClassifier 矢量数据输出的特征将包含由分类器决定的类别标签(最大类别标签=65535)。有两种模式:1)更新模式:在输入文件中添加包含预测类的‘cfield’字段。2)写入模式:将输入文件中已有的字段复制到输出文件中,并添加包含预测类的cfield字段。如果已声明输出文件,则应用写入模式。否则,将应用输入文件更新模式。

参数

Name of the input vector data -in vectorfile Mandatory
The input vector data file to classify.

Statistics file -instat filename [dtype]
A XML file containing mean and standard deviation to centerand reduce samples before classification, produced by ComputeImagesStatistics application.

Model file -model filename [dtype] Mandatory
Model file produced by TrainVectorClassifier application.

Output field -cfield string Default value: predicted
Field containing the predicted class.Only geometries with this field available will be taken into account. The field is added either in the input file (if 'out' off) or in the output file. Caution, the 'cfield' must not exist in the input file if you are updating the file.

Field names to be calculated -feat string1 string2...
List of field names in the input vector data used as features for training. Put the same field names as the TrainVectorClassifier application.

Confidence map -confmap bool Default value: false
Confidence map of the produced classification. The confidence index depends on the model:

  • LibSVM:两个最高概率之间的差异(需要一个带有概率估计的模型,以便可以为每个样本计算类别概率)
  • 助推:票数之和
  • DecisionTree:(不支持)
  • KNearestNeighbors:具有相同标签的邻居数量
  • 神经网络:两种最高反应之间的差异
  • Normal Bayes:(不支持)
  • RandomForest:信心(多数派的得票率)。利润率(两个多数派选票的归一化差异)目前不可用。
  • 支持向量机:距离到边距(仅适用于两类模型)

Output vector data file -out filename [dtype]
Output vector data file storing sample values (OGR format).If not given, the input vector data file is updated.

实例

从命令行执行以下操作:

otbcli_VectorClassifier -in vectorData.shp -instat meanVar.xml -model svmModel.svm -out vectorDataLabeledVector.shp -feat perimeter  area  width -cfield predicted

来自Python的评论:

import otbApplication

app = otbApplication.Registry.CreateApplication("VectorClassifier")

app.SetParameterString("in", "vectorData.shp")
app.SetParameterString("instat", "meanVar.xml")
app.SetParameterString("model", "svmModel.svm")
app.SetParameterString("out", "vectorDataLabeledVector.shp")
app.SetParameterStringList("feat", ['perimeter', 'area', 'width'])
app.SetParameterString("cfield", "predicted")

app.ExecuteAndWriteOutput()

局限性

支持Shapefile,但仅在更新模式下支持SQLite格式。