A GET request to the URI of the predictor we trained earlier results in a description response, showing that a predictor is just another transformer:

GET http://example.org/infer/knn_iris_20130802180742606
200 OK
    "psiType":        "transformer",
    "uri":            "http://example.org/infer/knn_iris_20130802180742606",
    "description":    "kNN trained predictor (trained on iris)",
    "accepts":        { "$array": { "items": [ "$number", "$number", "$number", "$number" ] } },
    "emits":          { "$string" { "enum": [ "setosa", "versicolor", "virginica" ] } },
    "provenance":     {
        "learner":    "http://example.org/learn/knn",
        "task": {
            "k": 3,
            "resources": {
                "source":  "$http://example.org/data/iris/array1",
                "target":  "$http://example.org/data/iris/flower/species"
        "created":    "2013-08-02T08:07Z"
    "update":         "http://example.org/infer/knn_iris_20130802180742606/update"

This response gives a lot of detail about the predictor and how to use it.

  • The optional provenance property contains an object that gives the learner URI and task that was used to create this predictor. Service providers can include whatever auditing information they wish in this structure.
  • The accepts schema defines valid input values, which in this case is arrays of four real-valued numbers.
  • The emits schema shows that this predictor’s output values are one of three possible string values: “setosa”, “versicolor” or “virginica”.
  • The presence of the update URI indicates this predictor can be updated with additional training instances.

Making a prediction

To use this predictor to classify a previously unseen instance value is identical to applying a transformer, so the input value must be valid for the accepts schema. In this case accepts defines arrays of four real-valued numbers, so the value [ 6.1, 2.1, 4.1, 1.7 ] would be an appropriate one for which to request a prediction:

GET http://example.org/infer/knn_iris_20130802180742606?value=[6.1,2.1,4.1,1.7]
200 OK
    "psiType":  "value",
    "value":    "versicolor"

Next steps

Since this predictor is updatable, we could give it additional training data. And if a new data source (relation) becomes available we may wish to create a new ‘predicting’ attribute for it by joining this predictor to one of its existing attributes.

Learning tasks & training Updating a predictor