The machine learning plugin provides machine learning functionality
as an aggregation function. It enables you to train Support Vector Machine (SVM)
based classifiers and regressors for the supervised learning problems.
The machine learning functions are not optimized for distributed processing.
The capability to train large data sets is limited by this execution of the
final training on a single instance.
To solve a problem with the machine learning technique, especially as a
supervised learning problem, it is necessary to represent the data set
with the sequence of pairs of labels and feature vector. A label is a
target value you want to predict from the unseen feature and a feature is a
A N-dimensional vector whose elements are numerical values. In Trino, a
feature vector is represented as a map-type value, whose key is an index
of each feature, so that it can express a sparse vector.
Since classifiers and regressors can recognize the map-type feature
vector, there is a function to construct the feature from the existing
numerical values, features():
Classification is a type of supervised learning problem to predict the distinct
label from the given feature vector. The interface looks similar to the
construction of the SVM model from the sequence of pairs of labels and features
implemented in Teradata Aster or BigQuery ML.
The function to train a classification model looks like as follows:
classify() returns the predicted label by using the trained model.
The trained model can not be saved natively, and needs to be passed in
the format of a nested query:
SELECT classify(features(5.9, 3, 5.1, 1.8), model) AS predicted_labelFROM ( SELECT learn_classifier(species, features(sepal_length, sepal_width, petal_length, petal_width)) AS model FROM iris) t
predicted_label----------------- Iris-virginica
As a result you need to run the training process at the same time when predicting values.
Internally, the model is trained by libsvm.
You can use learn_libsvm_classifier() to control the internal parameters of the model.
Regression is another type of supervised learning problem, predicting continuous
value, unlike the classification problem. The target must be numerical values that can
be described as double.The following code shows the creation of the model predicting sepal_length
from the other 3 features:
SELECT learn_regressor(sepal_length, features(sepal_width, petal_length, petal_width)) AS modelFROM iris
The way to use the model is similar to the classification case:
SELECT regress(features(3, 5.1, 1.8), model) AS predicted_targetFROM ( SELECT learn_regressor(sepal_length, features(sepal_width, petal_length, petal_width)) AS model FROM iris) t;
Returns a predicted target value by the given regressor SVM model.
Was this page helpful?
{"docsConfig":{"$schema":"https://mintlify.com/docs.json","theme":"mint","name":"Upsolve AI","colors":{"primary":"#F13470","light":"#F13470","dark":"#E05883"},"favicon":"https://mintcdn.com/upsolve/yo8HqJNiSHXxC-XO/favicon.svg?fit=max\u0026auto=format\u0026n=yo8HqJNiSHXxC-XO\u0026q=85\u0026s=9b9e554a8bc33ff2f4191464242d130d","logo":{"light":"https://mintcdn.com/upsolve/2iK7L-lfLcwqCcz_/logo/light_logo.svg?fit=max\u0026auto=format\u0026n=2iK7L-lfLcwqCcz_\u0026q=85\u0026s=e2c715b3dad371be16e683c74655b2a8","dark":"https://mintcdn.com/upsolve/2iK7L-lfLcwqCcz_/logo/dark_logo.svg?fit=max\u0026auto=format\u0026n=2iK7L-lfLcwqCcz_\u0026q=85\u0026s=e5b53eb0a41de94b806015890a6b4bdc","href":"https://upsolve.ai"},"api":{"openapi":["api-reference/upsolve.documentation.yaml"],"mdx":{"server":"https://api.upsolve.ai","auth":{"method":"bearer","name":null}}},"navbar":{"links":[{"label":"Support","href":"mailto:support@upsolve.ai"}],"primary":{"type":"button","label":"Request Access","href":"https://upsolve.ai/"}},"seo":{"metatags":{"slack-app-id":"A0C9DAKJQ49"},"indexing":"navigable"},"footer":{"socials":{"website":"https://upsolve.ai/","linkedin":"https://www.linkedin.com/company/upsolveai","hacker-news":"https://www.ycombinator.com/companies/upsolve-ai"}},"styling":{"latex":true},"navigation":{"global":{"anchors":[{"anchor":"Impact Studies","href":"https://upsolve.ai/impact-study","icon":"newspaper"},{"anchor":"Security Trust Center","href":"https://trust.upsolve.ai","icon":"shield-halved"},{"anchor":"Community","href":"https://upsolve-ai-community.slack.com/join/shared_invite/zt-2x9oospxx-vv2uDP_20IafkekwCOMi4A#/shared-invite/email","icon":"slack"},{"anchor":"Blog","href":"https://www.upsolve.com/blog","icon":"newspaper"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"upsolve","hasAudioNarration":false,"actualSubdomain":"upsolve","customDomains":["docs.upsolve.ai"],"gitSource":{"type":"github","owner":"upsolve-labs","repo":"upsolve-core","deployBranch":"main","contentDirectory":"apps/docs","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae5a12a3db8daa46796990a","collectionId":"62992c63-9dd9-4f69-8753-7cd0f54f68fa","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae5a12a3db8daa46796990a"},"feedback":{"thumbs":true,"edits":true,"issues":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae77ec8bfc5f43dec496d39","clientVersion":"0.0.4044","searchFilterCounts":[{"language":"default","tag":"API Reference","count":144},{"language":"default","tag":"API Documentation","count":143},{"language":"default","tag":"Integrations","count":116},{"language":"default","tag":"Documentation","count":48},{"language":"default","tag":"SQL Reference","count":48},{"language":"default","tag":"Canvases","count":29},{"language":"default","tag":"Workspace draft","count":29},{"language":"default","tag":"Functions","count":23},{"language":"default","tag":"Analytics Layer","count":22},{"language":"default","tag":"Connections \u0026 environments","count":19}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"sql/functions/ml","slug":"/sql/functions/ml","pageMetadata":{"title":"Machine learning functions","description":null,"href":"/sql/functions/ml"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`The machine learning plugin provides machine learning functionality\nas an aggregation function. It enables you to train Support Vector Machine (SVM)\nbased classifiers and regressors for the supervised learning problems.`}),`\n`,_jsx(Note,{children:_jsx(_components.p,{children:`The machine learning functions are not optimized for distributed processing.\nThe capability to train large data sets is limited by this execution of the\nfinal training on a single instance.`})}),`\n`,_jsx(Heading,{level:`2`,id:`feature-vector`,children:`Feature vector`}),`\n`,_jsxs(_components.p,{children:[`To solve a problem with the machine learning technique, especially as a\nsupervised learning problem, it is necessary to represent the data set\nwith the sequence of pairs of labels and feature vector. A label is a\ntarget value you want to predict from the unseen feature and a feature is a\nA N-dimensional vector whose elements are numerical values. In Trino, a\nfeature vector is represented as a map-type value, whose key is an index\nof each feature, so that it can express a sparse vector.\nSince classifiers and regressors can recognize the map-type feature\nvector, there is a function to construct the feature from the existing\nnumerical values, `,_jsx(_components.a,{href:`#features`,children:`features()`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` features(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` features;`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` features`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`-----------------------`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` {0=1.0, 1=2.0, 2=3.0}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`The output from `,_jsx(_components.a,{href:`#features`,children:`features()`}),` can be directly passed to ML functions.`]}),`\n`,_jsx(Heading,{level:`2`,id:`classification`,children:`Classification`}),`\n`,_jsxs(_components.p,{children:[`Classification is a type of supervised learning problem to predict the distinct\nlabel from the given feature vector. The interface looks similar to the\nconstruction of the SVM model from the sequence of pairs of labels and features\nimplemented in Teradata Aster or `,_jsx(_components.a,{href:`https://cloud.google.com/bigquery-ml/docs/bigqueryml-intro`,children:`BigQuery ML`}),`.\nThe function to train a classification model looks like as follows:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` learn_classifier(`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` species,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` features(sepal_length, sepal_width, petal_length, petal_width)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` model`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`FROM`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` iris`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`It returns the trained model in a serialized format.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` model`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`-------------------------------------------------`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` 3c 43 6c 61 73 73 69 66 69 65 72 28 76 61 72 63`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` 68 61 72 29 3e`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.a,{href:`#classify`,children:`classify()`}),` returns the predicted label by using the trained model.\nThe trained model can not be saved natively, and needs to be passed in\nthe format of a nested query:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`8`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` classify(features(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`5`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`9`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`5`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`8`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`), model) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` predicted_label`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`FROM`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` SELECT`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` learn_classifier(species, features(sepal_length, sepal_width, petal_length, petal_width)) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` model`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` FROM`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` iris`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) t`})}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` predicted_label`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`-----------------`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` Iris-virginica`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`As a result you need to run the training process at the same time when predicting values.\nInternally, the model is trained by `,_jsx(_components.a,{href:`https://www.csie.ntu.edu.tw/~cjlin/libsvm/`,children:`libsvm`}),`.\nYou can use `,_jsx(_components.a,{href:`#learn-libsvm-classifier`,children:`learn_libsvm_classifier()`}),` to control the internal parameters of the model.`]}),`\n`,_jsx(Heading,{level:`2`,id:`regression`,children:`Regression`}),`\n`,_jsxs(_components.p,{children:[`Regression is another type of supervised learning problem, predicting continuous\nvalue, unlike the classification problem. The target must be numerical values that can\nbe described as `,_jsx(_components.code,{children:`double`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`The following code shows the creation of the model predicting `,_jsx(_components.code,{children:`sepal_length`}),`\nfrom the other 3 features:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` learn_regressor(sepal_length, features(sepal_width, petal_length, petal_width)) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` model`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`FROM`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` iris`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`The way to use the model is similar to the classification case:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` regress(features(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`5`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`8`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`), model) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` predicted_target`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`FROM`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` SELECT`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` learn_regressor(sepal_length, features(sepal_width, petal_length, petal_width)) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` model`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` FROM`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` iris`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) t;`})}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` predicted_target`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`-------------------`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` 6.407376822560477`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`Internally, the model is trained by `,_jsx(_components.a,{href:`https://www.csie.ntu.edu.tw/~cjlin/libsvm/`,children:`libsvm`}),`.\n`,_jsx(_components.a,{href:`#learn-libsvm-regressor`,children:`learn_libsvm_regressor()`}),` provides you a way to control the training process.`]}),`\n`,_jsx(Heading,{level:`2`,id:`machine-learning-functions`,children:`Machine learning functions`}),`\n`,_jsx(Heading,{level:`3`,id:`features`,children:`features`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`features(double, ...) -> map(bigint, double)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Returns the map representing the feature vector.`}),`\n`,_jsx(Heading,{level:`3`,id:`learn_classifier`,children:`learn_classifier`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`learn_classifier(label, features) -> Classifier`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Returns an SVM-based classifier model, trained with the given label and feature data sets.`}),`\n`,_jsx(Heading,{level:`3`,id:`learn_libsvm_classifier`,children:`learn_libsvm_classifier`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`learn_libsvm_classifier(label, features, params) -> Classifier`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Returns an SVM-based classifier model, trained with the given label and feature data sets.\nYou can control the training process by libsvm parameters.`}),`\n`,_jsx(Heading,{level:`3`,id:`classify`,children:`classify`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`classify(features, model) -> label`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Returns a label predicted by the given classifier SVM model.`}),`\n`,_jsx(Heading,{level:`3`,id:`learn_regressor`,children:`learn_regressor`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`learn_regressor(target, features) -> Regressor`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Returns an SVM-based regressor model, trained with the given target and feature data sets.`}),`\n`,_jsx(Heading,{level:`3`,id:`learn_libsvm_regressor`,children:`learn_libsvm_regressor`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`learn_libsvm_regressor(target, features, params) -> Regressor`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Returns an SVM-based regressor model, trained with the given target and feature data sets.\nYou can control the training process by libsvm parameters.`}),`\n`,_jsx(Heading,{level:`3`,id:`regress`,children:`regress`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`regress(features, model) -> target`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Returns a predicted target value by the given regressor SVM model.`})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Machine learning functions","description":null,"href":"/sql/functions/ml"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Feature vector","slug":"feature-vector","depth":2,"children":[]},{"title":"Classification","slug":"classification","depth":2,"children":[]},{"title":"Regression","slug":"regression","depth":2,"children":[]},{"title":"Machine learning functions","slug":"machine-learning-functions","depth":2,"children":[{"title":"features","slug":"features","depth":3,"children":[]},{"title":"learn_classifier","slug":"learn_classifier","depth":3,"children":[]},{"title":"learn_libsvm_classifier","slug":"learn_libsvm_classifier","depth":3,"children":[]},{"title":"classify","slug":"classify","depth":3,"children":[]},{"title":"learn_regressor","slug":"learn_regressor","depth":3,"children":[]},{"title":"learn_libsvm_regressor","slug":"learn_libsvm_regressor","depth":3,"children":[]},{"title":"regress","slug":"regress","depth":3,"children":[]}]}],"codeExamples":{}},"jsLinks":[],"subdomain":"upsolve","siteName":"Upsolve AI","title":"Machine learning functions - Upsolve AI","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-01T18:03:18.020Z","originalFileLocation":"sql/functions/ml.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"Upsolve AI\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/upsolve/294UabaKv711UkJe/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/upsolve/294UabaKv711UkJe/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/upsolve/294UabaKv711UkJe/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/upsolve/294UabaKv711UkJe/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/upsolve/294UabaKv711UkJe/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/upsolve/294UabaKv711UkJe/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/upsolve/294UabaKv711UkJe/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/upsolve/294UabaKv711UkJe/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/upsolve/294UabaKv711UkJe/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Machine learning functions - Upsolve AI\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Upsolve AI\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.upsolve.ai/sql/functions/ml\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://upsolve.mintlify.app/_mintlify/api/og/v2?division=Functions\u0026amp;title=Machine+learning+functions\u0026amp;theme=ee308efe25f936e82bf32ff5\u0026amp;signature=64fe78a10a6bb14b6a0fc1a8a704659c1663230f791df0ec522cb3d70b64c0f1\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Machine learning functions - Upsolve AI\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://upsolve.mintlify.app/_mintlify/api/og/v2?division=Functions\u0026amp;title=Machine+learning+functions\u0026amp;theme=ee308efe25f936e82bf32ff5\u0026amp;signature=64fe78a10a6bb14b6a0fc1a8a704659c1663230f791df0ec522cb3d70b64c0f1\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/upsolve/294UabaKv711UkJe/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Upsolve AI\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#F13470\">\u003cmeta data-mint-head name=\"slack-app-id\" content=\"A0C9DAKJQ49\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.upsolve.ai/sql/functions/ml\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/sql/functions/ml.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.upsolve.ai/#organization\",\"name\":\"Upsolve AI\",\"url\":\"https://docs.upsolve.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/upsolve/2iK7L-lfLcwqCcz_/logo/light_logo.svg?fit=max\u0026auto=format\u0026n=2iK7L-lfLcwqCcz_\u0026q=85\u0026s=e2c715b3dad371be16e683c74655b2a8\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.upsolve.ai#website\",\"name\":\"Upsolve AI\",\"url\":\"https://docs.upsolve.ai\",\"publisher\":{\"@id\":\"https://docs.upsolve.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.upsolve.ai/sql/functions/ml#webpage\",\"url\":\"https://docs.upsolve.ai/sql/functions/ml\",\"name\":\"Machine learning functions\",\"dateModified\":\"2026-11-01T18:03:18.020Z\",\"isPartOf\":{\"@id\":\"https://docs.upsolve.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.upsolve.ai/sql/functions/ml#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.upsolve.ai/sql/functions/ml#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Functions\",\"item\":\"https://docs.upsolve.ai/sql/functions/aggregate\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Machine learning functions\",\"item\":\"https://docs.upsolve.ai/sql/functions/ml\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.upsolve.ai/sql/functions/ml#article\",\"headline\":\"Machine learning functions\",\"name\":\"Machine learning functions\",\"url\":\"https://docs.upsolve.ai/sql/functions/ml\",\"mainEntityOfPage\":{\"@id\":\"https://docs.upsolve.ai/sql/functions/ml#webpage\"},\"dateModified\":\"2026-11-01T18:03:18.020Z\",\"publisher\":{\"@id\":\"https://docs.upsolve.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.upsolve.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Upsolve AI\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Upsolve AI","nav":{"global":{"anchors":[{"anchor":"Impact Studies","href":"https://upsolve.ai/impact-study","icon":"newspaper"},{"anchor":"Security Trust Center","href":"https://trust.upsolve.ai","icon":"shield-halved"},{"anchor":"Community","href":"https://upsolve-ai-community.slack.com/join/shared_invite/zt-2x9oospxx-vv2uDP_20IafkekwCOMi4A#/shared-invite/email","icon":"slack"},{"anchor":"Blog","href":"https://www.upsolve.com/blog","icon":"newspaper"}]},"tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":"/introduction"}]},{"tab":"Analytics Layer","pages":[{"title":"Analytics Layer","href":"/embedded-bi/introduction"}]},{"tab":"Integrations","pages":[{"title":"Integrations","href":"/integrations/introduction"}]},{"tab":"Chart Configurations","pages":[{"title":"Chart Configurations","href":"/content/charts/area-line-chart"}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/v2/migrate-from-v1"}]},{"tab":"SQL Reference","groups":[{"group":"SQL","pages":[{"title":"Introduction","href":"/sql/introduction"}]},{"group":"Reference","pages":[{"title":"DESCRIBE","href":"/sql/reference/describe"},{"title":"EXECUTE","href":"/sql/reference/execute"},{"title":"PREPARE","href":"/sql/reference/prepare"},{"title":"SELECT","href":"/sql/reference/select"},{"title":"SHOW CATALOGS","href":"/sql/reference/show-catalogs"},{"title":"SHOW COLUMNS","href":"/sql/reference/show-columns"},{"title":"SHOW SCHEMAS","href":"/sql/reference/show-schemas"},{"title":"USE","href":"/sql/reference/use"},{"title":"VALUES","href":"/sql/reference/values"}]},{"group":"Data Types","pages":[{"title":"Data types","href":"/sql/reference/types"}]},{"group":"Functions","pages":[{"title":"Aggregate functions","href":"/sql/functions/aggregate"},{"title":"Array functions and operators","href":"/sql/functions/array"},{"title":"Binary functions and operators","href":"/sql/functions/binary"},{"title":"Bitwise functions","href":"/sql/functions/bitwise"},{"title":"Comparison functions and operators","href":"/sql/functions/comparison"},{"title":"Conditional Expressions","href":"/sql/functions/conditional"},{"title":null,"href":"/sql/functions/conversion"},{"title":"Date and time functions and operators","href":"/sql/functions/datetime"},{"title":"Decimal functions and operators","href":"/sql/functions/decimal"},{"title":"HyperLogLog Functions","href":"/sql/functions/hyperloglog"},{"title":"JSON functions and operators","href":"/sql/functions/json"},{"title":"Lambda expressions","href":"/sql/functions/lambda"},{"title":null,"description":null,"href":"/sql/functions/map"},{"title":"Machine learning functions","href":"/sql/functions/ml"},{"title":"Quantile digest functions","description":null,"href":"/sql/functions/qdigest"},{"title":null,"href":"/sql/functions/regexp"},{"title":"Set Digest functions","href":"/sql/functions/setdigest"},{"title":"String functions and operators","href":"/sql/functions/string"},{"title":"Table functions","href":"/sql/functions/table"},{"title":"Teradata functions","href":"/sql/functions/teradata"},{"title":"URL functions","href":"/sql/functions/url"},{"title":"UUID Functions","href":"/sql/functions/uuid"},{"title":"Window functions","href":"/sql/functions/window"}]},{"group":"Routines","pages":[{"title":"Introduction to SQL routines","href":"/sql/routines/introduction"},{"title":"Example SQL routines","href":"/sql/routines/examples"},{"title":"BEGIN","href":"/sql/routines/begin"},{"title":"CASE","href":"/sql/routines/case"},{"title":"DECLARE","href":"/sql/routines/declare"},{"title":"FUNCTION","href":"/sql/routines/function"},{"title":"IF","href":"/sql/routines/if"},{"title":"ITERATE","href":"/sql/routines/iterate"},{"title":"LEAVE","href":"/sql/routines/leave"},{"title":"LOOP","href":"/sql/routines/loop"},{"title":"REPEAT","href":"/sql/routines/repeat"},{"title":"RETURN","href":"/sql/routines/return"},{"title":"SET","href":"/sql/routines/set"},{"title":"WHILE","href":"/sql/routines/while"}]}]},{"tab":"Demo","pages":[{"title":"Demo","href":"/demo/product-walkthrough"}]}]},"basePath":"","title":"Machine learning functions - Upsolve AI","buildId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","deploymentId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","dynamics":[],"chunks":[]}