

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# SPARQL 对象分类示例
<a name="machine-learning-sparql-inference-object-classification"></a>

对于 Neptune ML 中的 SPARQL 对象分类，模型是根据其中一个谓词值进行训练的。当给定主题中还没有该谓词时，这很有用。

使用对象分类模型只能推理分类谓词值。

下面的查询试图预测类型为 `foaf:Person` 的所有输入的 <http://www.example.org/team> 谓词值：

```
SELECT * WHERE { ?input a foaf:Person .
  SERVICE neptune-ml:inference {
    neptune-ml:config neptune-ml:modelType 'OBJECT_CLASSIFICATION' ;
                      neptune-ml:input ?input ;
                      neptune-ml:predicate <http://www.example.org/team> ;
                      neptune-ml:output ?output .
  }
}
```

可以按如下方式自定义此查询：

```
SELECT * WHERE { ?input a foaf:Person .
  SERVICE neptune-ml:inference {
    neptune-ml:config neptune-ml:endpoint 'node-prediction-account-balance-endpoint' ;
                      neptune-ml:iamRoleArn 'arn:aws:iam::0123456789:role/sagemaker-role' ;

                      neptune-ml:batchSize "40"^^xsd:integer ;
                      neptune-ml:timeout "1000"^^xsd:integer ;

                      neptune-ml:modelType 'OBJECT_CLASSIFICATION' ;
                      neptune-ml:input ?input ;
                      neptune-ml:predicate <http://www.example.org/team> ;
                      neptune-ml:output ?output .
  }
}
```