Skip to main content

MARKOV_TRAIN

Extracting patterns from datasets using Markov models

Syntax

MARKOV_TRAIN(<string>)

MARKOV_TRAIN(<order>)(<string>)

MARKOV_TRAIN(<order>, <frequency_cutoff>, <num_buckets_cutoff>, <frequency_add>, <frequency_desaturate>) (<string>)

Arguments

ArgumentsDescription
stringInput
orderOrder of markov model to generate strings
frequency-cutoffFrequency cutoff for markov model: remove all buckets with count less than specified
num-buckets-cutoffCutoff for number of different possible continuations for a context: remove all histograms with less than specified number of buckets
frequency-addAdd a constant to every count to lower probability distribution skew
frequency-desaturate0..1 - move every frequency towards average to lower probability distribution skew

Return Type

Depending on the implementation, it is only used as a argument for MARKOV_GENERATE.

Examples

create table model as
select markov_train(concat('bar', number::string)) as bar from numbers(100);

select markov_generate(bar,'{"order":5,"sliding_window_size":8}', 151, (number+100000)::string) as generate
from numbers(5), model;
+-----------+
| generate |
+-----------+
│ bar95 │
│ bar64 │
│ bar85 │
│ bar56 │
│ bar95 │
+-----------+
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today