Intro to Functions

User-defined Functions are named, reusable programs used to implement streaming computations which can accept input values and return output values. Functions are used to:

Functions can be created directly via a REST API call or by passing a functionName argument to most training Procedures.

Input and Output Values

Functions have a fixed set of input values and output values. Input and output values can be either scalar or variable-length row-like values. The input and output values are named so that it is easy to identify them. Also, this permits function's output values to be passed as another function's input values. This composition of functions can be done using the serial function type.

Applying Function via REST Endpoints

All MLDB Functions are automatically accessible as REST Endpoints, which can be used to apply machine learning models in a streaming/real-time process. Functions can be applied via a REST API call like GET /v1/functions/<id>/application?input={<values>}.

Functions support input values passed in as query string parameters or as a JSON payload. In both cases, the REST call must be a GET.

Applying Function via SQL

In MLDB SQL, Functions can be applied much like built-in functions: they accept a row as input and return a row as output.

Available Function Types

Functions are created via a REST API call with one of the following types:

TypeDescriptionDoc
classifierApply a trained classifier to new data[doc]
classifier.explainExplain the output of a classifier[doc]
embedding.neighborsReturn the nearest neighbors of a known row in an embedding dataset[doc]
feature_hasherFeature hashing feature generator[doc]
fetcherFetches the contents of a URL each time it's invoked[doc]
http.useragentParse user agent strings into their components[doc]
image.proximatevoxelsFind values in a cubic volume inside a 3d embedding[doc]
image.readpixelsWraps access to a 2d embedding[doc]
kmeansApply a k-means clustering to new data[doc]
mongodb.queryTakes a MongoDB query, forwards it to MongDB, parses the result and returns it as an MLDB result.[doc]
poolingApply a pooling function[doc]
probabilizerApply a probability calibration model[doc]
sql.expressionRun an SQL expression as a function[doc]
sql.queryRun a single row SQL query against a dataset[doc]
statsTable.bagOfWords.posnegGet the pos/neg p(outcome)[doc]
statsTable.getCountsGet stats table counts for a row of keys[doc]
stemmerApply a stemming algorithm column names[doc]
stemmerdocApply a stemming algorithm on a single document[doc]
svd.embedRowApply a trained SVD to embed a row into a coordinate space[doc]
tensorflow.graphGraph parameters for a trained TensorFlow model[doc]
tfidfApply a TF-IDF scoring to a bag of words[doc]
tokensplitInsert spaces after tokens from a dictionary[doc]

See also