Home > Hadrian > Overview

Overview

In addition to providing a general way to plug Jython code into PFA applications, Antinous produces models. Only k-means has been implemented.

Producer interface

Antinous producers adhere to the following suite of abstract interfaces in com.opendatagroup.antinous.producer.

The package also has a random number seed, which is used to randomize all producer algorithms. It can be set via

The usual procedure is to create a concrete Dataset in the global Jython namespace and fill it in the action phase, then create a Producer from that Dataset, run optimize() to make a Model and emit PFA in the end phase.

Here is an example that builds a k-means clustering model for one key in a Hadoop reducer (one segment of the whole model).

from antinous import *
from com.opendatagroup.antinous.producer.kmeans import VectorSet, KMeans

input = record(key = string, value = array(double))
output = record(segment = string,
                clusters = array(record(center = array(double),
                weight = double)))

segment = None
vectorSet = VectorSet()

def action(input):
    global segment, vectorSet
    segment = input.key
    vectorSet.add(input.value)

def end():
    if segment is not None:
        kmeans = KMeans(3, vectorSet)
        kmeans.optimize()
        emit({"segment": segment, "clusters": kmeans.model().pfa()})

K-means producer

In package com.opendatagroup.antinous.producer.kmeans,

Metrics adhere to interface Metric and can be constructed with:

Stopping conditions adhere to interface StoppingCondition and can be constructed with: