> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://ocient.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://ocient.ferndocs.com/_mcp/server.

# Machine Learning Model Functions

> Implement machine learning model functions in Ocient with OcientML for advanced predictive and analytical capabilities.

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

> **Note**
>
> 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.

> **Note**
>
> For functions to help organize data before training a model, see [**Data Preparation**](/guides/sql-reference/machine-learning-model-functions/data-preparation).

### Regression Models

* [**Simple Linear Regression**](/guides/sql-reference/machine-learning-model-functions/regression-models)
* [**Multiple Linear Regression**](/guides/sql-reference/machine-learning-model-functions/regression-models)
* [**Vector Autoregression**](/guides/sql-reference/machine-learning-model-functions/regression-models)
* [**Polynomial Regression**](/guides/sql-reference/machine-learning-model-functions/regression-models)
* [**Linear Combination Regression**](/guides/sql-reference/machine-learning-model-functions/regression-models)
* [**Nonlinear Regression**](/guides/sql-reference/machine-learning-model-functions/regression-models)
* [**Gradient Boosted Trees**](/guides/sql-reference/machine-learning-model-functions/regression-models)
* [**Regression Tree**](/guides/sql-reference/machine-learning-model-functions/regression-models)

### Classification Models

* [**K Nearest Neighbor Classification**](/guides/sql-reference/machine-learning-model-functions/classification-models)
* [**Naive Bayes Classification**](/guides/sql-reference/machine-learning-model-functions/classification-models)
* [**Decision Tree**](/guides/sql-reference/machine-learning-model-functions/classification-models)
* [**Random Forest**](/guides/sql-reference/machine-learning-model-functions/classification-models)
* [**Logistic Regression**](/guides/sql-reference/machine-learning-model-functions/classification-models)
* [**Support Vector Machine**](/guides/sql-reference/machine-learning-model-functions/classification-models)
* [**Gradient Boosted Trees**](/guides/sql-reference/machine-learning-model-functions/classification-models)

### Clustering and Dimension Reduction Models

* [**Principal Component Analysis**](/guides/sql-reference/machine-learning-model-functions/clustering-and-dimension-reduction-models)
* [**K-Means Clustering**](/guides/sql-reference/machine-learning-model-functions/clustering-and-dimension-reduction-models)
* [**Gaussian Mixture**](/guides/sql-reference/machine-learning-model-functions/clustering-and-dimension-reduction-models)
* [**Linear Discriminant Analysis**](/guides/sql-reference/machine-learning-model-functions/clustering-and-dimension-reduction-models)

### Other Models

* [**Association Rules**](/guides/sql-reference/machine-learning-model-functions/other-models)
* [**Feedforward Neural Network**](/guides/sql-reference/machine-learning-model-functions/other-models)

# Execute a Query Using a Machine Learning Model

To create a machine learning model and manage the model, see [**Machine Learning Models**](/guides/sql-reference/data-definition-language-ddl-statement-reference/machine-learning-models) for the corresponding syntax. After you create the model, you can execute a query using the model with this syntax.

**Syntax**

```sql
SELECT model_name ( expression [, ... ] ) FROM table_reference
```

| **Parameter**     | **Data Type**              | **Description**                                                                                                                                                                                                                                                                                                                        |
| ----------------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model_name`      | identifier                 | The 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.                                                                                                                                                                  |
| `expression`      | identifier 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_reference` | identifier                 | The 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.

```sql
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.

```sql
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.

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

*Output*

```none
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**](/guides/analysis-in-ocient/machine-learning-in-ocient)

[**Machine Learning Models**](/guides/sql-reference/data-definition-language-ddl-statement-reference/machine-learning-models)