A version of the Iris data set is made available as a PSI relation at the URI http://example.org/data/iris, which was obtained from the service’s relations collection. A description of the relation is obtained using a GET request to that URI.

GET http://example.org/data/iris
200 OK
{
    "psiType":           "relation",
    "uri":               "http://example.org/data/iris",
    "description":       "The iris data set, courtesy of Sir R. A. Fisher",
    "size":              150,
    "defaultAttribute":    "http://example.org/data/iris/flower",
    "attributes":        [
        "http://example.org/data/iris/flower",
        "http://example.org/data/iris/features",
        "http://example.org/data/iris/image"
    ],
    "querySchema": { ... }
}

This description response shows that the relation has 150 instances and they can be represented using the default attribute at http://example.org/data/iris/flower. The relation has two additional attributes at http://example.org/data/iris/features and http://example.org/data/iris/image (which is examined in another example).

The presence of the querySchema property indicates that this relation can be queried. Details of the query schema are examined elsewhere, so have been omitted from all example responses on this page for brevity.

Inspecting an attribute

A GET request to the default attribute URI reveals its description, emits schema, relation, and sub-attributes:

GET http://example.org/data/iris/flower
200 OK
{
    "psiType":      "attribute",
    "uri":          "http://example.org/data/iris/flower",
    "description":  "A structured attribute for presenting iris dimensions",
    "relation":     "http://example.org/data/iris",
    "emits": {
        "/sepal": { "/length": "$number", "/width": "$number" },
        "/petal": { "/length": "$number", "/width": "$number" } 
        "/species": { "$string": { "enum": [ "setosa", "versicolor", "virginica" } }
    },
    "subattributes": {
        "sepal":   "http://example.org/data/iris/flower/sepal",
        "petal":   "http://example.org/data/iris/flower/petal",
        "species": "http://example.org/data/iris/flower/species"
    },
    "querySchema": { ... }
}

From this description it is clear that this attribute returns values that are objects with a sepal and petal properties, and the value for those properties are objects with length and width properties that must contain numeric values. It also shows that this attribute returns values with a species property that can take on the string values “setosa”, “versicolor”, or “virginica”. (In this example, assume that the relation’s other attribute, features, also produces object values representing iris flowers, but without the species property.)

The description also shows that this structured attribute has three sub-attributes, accessible at http://example.org/data/iris/flower/sepal, http://example.org/data/iris/flower/petal, and http://example.org/data/iris/flower/species. GET requests to these URIs can be used to obtain more information. For example, the petal sub-attribute responds with:

GET http://example.org/data/iris/flower/petal
200 OK
{
    "psiType":       "attribute",
    "uri":           "http://example.org/data/iris/flower/petal",
    "relation":      "http://example.org/data/iris",
    "emits":        { "/length": "$number", "/width": "$number" },
    "subattributes": [
        "length": "http://example.org/data/iris/flower/petal/length",
        "width":  "http://example.org/data/iris/flower/petal/width"
    ],
    "querySchema": { ... }
}

Viewing a relation’s data through its attributes

To get the value of the first instance in the Iris relation using the default attribute the following GET request can be made:

GET http://example.org/data/iris/flower?instance=1
200 OK
{
    "psiType":  "value",
    "value":    {
        "sepal": { "length": 5.1, "width": 3.5 },
        "petal": { "length": 1.4, "width": 0.2 },
        "species": "setosa"
    }
}

Applying the species sub-attribute to the entire Iris relation yields an array of string values (the ellipsis denotes 145 elided values in the array):

GET http://example.org/data/iris/flower/species?instance=all
200 OK
{
    "psiType":    "value",
    "valueList":  [ 
        "setosa", "setosa", "setosa", ..., "virginica", "virginica"
    ]
}

Next steps

Now we can obtain all the data from a relation we may wish to perform a query on it to select a subset of instances, transform it, or find out what learning algorithms we could apply to the data.

Discovering a PSI service Querying a relation