Skip to navigation

Machine Learning Model Functions

View as Markdown

OcientML™ functionality supports these SQL functions for machine learning models.

The scope of a machine learning model is the schema.

Supported Machine Learning Models

Supported machine learning models and reference material are divided into these categories.

For functions to help organize data before training a model, see Data Preparation.

Regression Models

Classification Models

Clustering and Dimension Reduction Models

Other Models

Execute a Query Using a Machine Learning Model

To create a machine learning model and manage the model, see Machine Learning Models for the corresponding syntax. After you create the model, you can execute a query using the model with this syntax.

Syntax

SELECT model_name ( expression [, ... ] ) FROM table_reference
ParameterData TypeDescription
model_nameidentifierThe name of a machine learning model created using a CREATE MODEL SQL statement. The model name must be a valid identifier and reference an existing trained model.
expressionidentifier
string
numeric
One or more expressions that serve as input features for the machine learning model evaluation. These expressions must match the expected input schema the model was trained on.

Expressions can be any combination of literal values, column names, arithmetic expressions, and function invocations, with parentheses for grouping.
table_referenceidentifierThe name of a table, view, or subquery that provides the data for model evaluation. The table must contain columns or computed expressions that match the expected input features of the model.

Example

Create a table with data for the model.

CREATE TABLE mldemo.mlr AS (SELECT a.c1 AS x1, b.c1 AS x2, 1 + 2*a.c1 + 3*b.c1 AS y
FROM sys.dummy10 a, sys.dummy10 b);
Modified 100 rows

Create a multiple linear regression model based on the data.

CREATE MLMODEL mlr_model TYPE MULTIPLE LINEAR REGRESSION ON (SELECT * FROM mldemo.mlr)
options('metrics' -> 'true');
Modified 0 rows

Execute a SELECT query against the multiple linear regression to see the actual and predicted values. Limit the result set to 10 rows.

SELECT x1, x2, y AS actual, mlr_model(x1, x2) AS predicted
FROM mldemo.mlr
LIMIT 10;

Output

x1 x2 actual predicted
----------------------------------------------------------------
6 1 16 15.999999999999975
6 2 19 18.999999999999975
6 3 22 21.999999999999975
6 4 25 24.999999999999975
6 5 28 27.999999999999975
6 6 31 30.999999999999975
6 7 34 33.99999999999997
6 8 37 36.99999999999997
6 9 40 39.99999999999997
6 10 43 42.99999999999997
Fetched 10 rows

Related Links

Machine Learning in Ocient

Machine Learning Models