The simples API for accessing ELKI results is the ResultHandler API.
In this tutorial, we will implement a custom result handler to output data in our preferred custom format.
Auto-generated code
Implementing the interface yields the following template stub:
Finding Outlier Results
For this example, we want to access the result of an outlier detection algorithm. First of all, we will need to scan the current result tree for appropriate outlier detection results. Fortunately, the ResultUtil class already implements this job for us:
Accessing the scores
Our output format will be a simple list of object id and outlier scores. For this we just iterate over all objects, print their ID and score:
Putting it all together
The complete class looks like this:
The class should show up automatically in the -resulthandler choices of the UI.
Since there is an implicit parameterless public constructor, it can automatically be instantiated, and we do not have to add an Parameterizer.
Similarly, we could search for Clustering results, iterate over the clusters and print each clusters object IDs:
Object numbering
ELKI will use a continuous object numbering by default. If you want the object IDs to always start at 0, use e.g. a FixedDBIDsFilter to use a static numbering scheme.