Skip to main content
Skip to main content

Machine Learning Functions

Note

The documentation below is automatically generated from system.functions

evalMLMethod

Introduced in: v20.1.0

Applies a trained machine learning model to input features to generate predictions.

Syntax

evalMLMethod(model, x1[, x2, ...])

Arguments

Returned value

Returns the predicted value based on the trained model. Float64

Examples

Example usage

SELECT
evalMLMethod(model, trip_distance),
total_amount
FROM trips
LEFT JOIN models ON year = toYear(pickup_datetime)
LIMIT 5
┌─evalMLMethod(model, trip_distance)─┬─total_amount─┐
│ 8.087692004204174                  │ 5.4          │
│ 7.861181608305352                  │ 4.6          │
│ 26.661544467907536                 │ 23.4         │
│ 8.767223191900637                  │ 5.8          │
│ 10.80581675499003                  │ 9            │
└────────────────────────────────────┴──────────────┘

naiveBayesClassifier

Introduced in: v25.11.0

Classifies input text using a NAIVE_BAYES dictionary. Returns the same predicted class value as dictGet(dictionary_name, class_attribute, input_text), where class_attribute is the name of the class label attribute configured in the dictionary's layout. Unlike dictGet, the result type is always UInt32 rather than the declared type of the class attribute, and input_text must be a String (no key type conversion is applied).

Note

This function is non-deterministic: it can return different results for the same arguments.

Syntax

naiveBayesClassifier(dictionary_name, input_text)

Arguments

  • dictionary_name — Name of a dictionary with the NAIVE_BAYES layout. String
  • input_text — Text to classify. String

Returned value

Predicted class ID. UInt32

Examples

Classify text

SELECT naiveBayesClassifier('model', 'some text');
0

naiveBayesClassifierWithAllProbs

Introduced in: v26.7.0

Classifies input text using a NAIVE_BAYES dictionary and returns all classes with their probabilities, ordered from most to least probable.

Note

This function is non-deterministic: it can return different results for the same arguments.

Syntax

naiveBayesClassifierWithAllProbs(dictionary_name, input_text)

Arguments

  • dictionary_name — Name of a dictionary with the NAIVE_BAYES layout. String
  • input_text — Text to classify. String

Returned value

Array of (class_id, probability) tuples ordered from most to least probable. Array(Tuple(UInt32, Float64))

Examples

All class probabilities

SELECT naiveBayesClassifierWithAllProbs('model', 'some text');
[(0,0.85),(1,0.15)]

naiveBayesClassifierWithProb

Introduced in: v26.7.0

Classifies input text using a NAIVE_BAYES dictionary and returns the predicted class with its probability.

Note

This function is non-deterministic: it can return different results for the same arguments.

Syntax

naiveBayesClassifierWithProb(dictionary_name, input_text)

Arguments

  • dictionary_name — Name of a dictionary with the NAIVE_BAYES layout. String
  • input_text — Text to classify. String

Returned value

Tuple of (class_id, probability). Tuple(UInt32, Float64)

Examples

Classify with probability

SELECT naiveBayesClassifierWithProb('model', 'some text');
(0,0.85)