{"id":12792,"date":"2022-02-16T08:34:12","date_gmt":"2022-02-16T16:34:12","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=12792"},"modified":"2025-06-13T21:25:06","modified_gmt":"2025-06-14T04:25:06","slug":"leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/pt\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/","title":{"rendered":"Aproveitamento de seus modelos de ML com as fun\u00e7\u00f5es definidas pelo usu\u00e1rio (UDF) do Couchbase Analytics"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Com o Couchbase 7.0, agora voc\u00ea pode permitir a integra\u00e7\u00e3o de UDFs do Python com o Couchbase Analytics. Em <a href=\"https:\/\/www.couchbase.com\/blog\/pt\/ml-meets-nosql-integrating-python-user-defined-functions-with-n1ql-for-analytics\/\">Parte 1 desta s\u00e9rie do blog<\/a>Na se\u00e7\u00e3o \"Como configurar o Couchbase\", abordamos os aspectos essenciais para configurar o Couchbase e o Analytics for Machine Learning (ML).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">O ML transformou radicalmente as maneiras pelas quais as organiza\u00e7\u00f5es entendem as necessidades de seus clientes. Os dom\u00ednios de an\u00e1lise avan\u00e7ada, como a an\u00e1lise preditiva (rotatividade de clientes, sentimento do cliente etc.) e a modelagem financeira, est\u00e3o cada vez mais dependentes do processamento de dados em escala, quase em tempo real, e da extra\u00e7\u00e3o de insights valiosos.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Para ajudar nossos clientes a obter insights anal\u00edticos em tempo real, criamos um pipeline cont\u00ednuo de modelos de aprendizado de m\u00e1quina baseados em Python para o Couchbase Analytics. Nesta postagem, eu passo pelas etapas a seguir para mostrar a voc\u00ea como aplicar algoritmos externos a dados residentes no Couchbase.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Seis etapas para aplicar modelos de ML em seus dados NoSQL:<\/span><\/h4>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Treinar o modelo<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Codificar o modelo<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Empacotar e implantar o c\u00f3digo<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Importar os dados necess\u00e1rios para este projeto<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Escrevendo o UDF<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Usando o UDF em sua inst\u00e2ncia para o CB (Modo DP)<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Antes de come\u00e7armos, vamos encontrar um conjunto de dados que ser\u00e1 uma demonstra\u00e7\u00e3o interessante dos recursos que estamos criando. H\u00e1 resenhas de filmes em v\u00e1rios sites diferentes, mas para ter uma compreens\u00e3o hol\u00edstica das resenhas dos cr\u00edticos, n\u00e3o h\u00e1 lugar melhor do que o Rotten Tomatoes. Esse site permite comparar as classifica\u00e7\u00f5es dadas por usu\u00e1rios comuns (pontua\u00e7\u00e3o do p\u00fablico) e as classifica\u00e7\u00f5es ou resenhas dadas pelos cr\u00edticos (<em>tomat\u00f4metro<\/em>) que s\u00e3o membros certificados de v\u00e1rias corpora\u00e7\u00f5es de escritores ou associa\u00e7\u00f5es de cr\u00edticos de cinema.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Os dois conjuntos de dados usados para este blog podem ser encontrados em <\/span><a href=\"https:\/\/www.kaggle.com\/stefanoleone992\/rotten-tomatoes-movies-and-critic-reviews-dataset\"><span style=\"font-weight: 400;\">kaggle.com<\/span><\/a><span style=\"font-weight: 400;\">. Esses arquivos s\u00e3o bastante grandes, portanto, um link para eles \u00e9 fornecido para que voc\u00ea possa baix\u00e1-los quando estiver acompanhando.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">No <\/span><em><span style=\"font-weight: 400;\">filmes<\/span><\/em><span style=\"font-weight: 400;\"> cada registro representa um filme dispon\u00edvel no Rotten Tomatoes, com o URL usado para extrair o t\u00edtulo do filme, a descri\u00e7\u00e3o, os g\u00eaneros, a dura\u00e7\u00e3o, o diretor, os atores, as classifica\u00e7\u00f5es dos usu\u00e1rios e as classifica\u00e7\u00f5es dos cr\u00edticos. No <\/span><em><span style=\"font-weight: 400;\">cr\u00edticas de filmes<\/span><\/em><span style=\"font-weight: 400;\"> cada registro representa uma resenha cr\u00edtica publicada no Rotten Tomatoes, com o URL usado para extrair o nome do cr\u00edtico, a publica\u00e7\u00e3o da resenha, a data, a pontua\u00e7\u00e3o e o conte\u00fado.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Treinamento do modelo de ML<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Antes de come\u00e7ar a explorar o poder da integra\u00e7\u00e3o entre ML e NoSQL, voc\u00ea precisar\u00e1 desenvolver e treinar um modelo de aprendizado de m\u00e1quina em Python.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Para os fins deste blog, usaremos um modelo simples de regress\u00e3o log\u00edstica que utiliza a biblioteca scikit-learn. Em sua ess\u00eancia, o modelo recebe dados e analisa seus sentimentos em rela\u00e7\u00e3o \u00e0s cr\u00edticas de filmes. Voc\u00ea pode seguir as etapas descritas abaixo ou fazer o download de todos os arquivos necess\u00e1rios em nosso <\/span><a href=\"https:\/\/github.com\/couchbaselabs\/AnalyticsML\"><span style=\"font-weight: 400;\">Reposit\u00f3rio do GitHub<\/span><\/a><span style=\"font-weight: 400;\">.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Para este blog, estamos usando um algoritmo preditivo de c\u00f3digo aberto no conjunto de dados de resenhas de filmes para determinar o sentimento, ou seja, para determinar se as resenhas s\u00e3o positivas ou negativas para um determinado filme. Nos exemplos de hoje, j\u00e1 treinamos o modelo usando um subconjunto do arquivo que voc\u00ea baixou anteriormente. Para os fins deste blog, utilizamos um arquivo CSV (valores separados por v\u00edrgula) para importar nossos dados.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Abaixo est\u00e1 um exemplo do c\u00f3digo do pr\u00f3prio modelo:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12793\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/02\/python.png\" alt=\"\" width=\"1600\" height=\"1152\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python.png 1600w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python-300x216.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python-1024x737.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python-768x553.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python-1536x1106.png 1536w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python-20x14.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python-1320x950.png 1320w\" sizes=\"auto, (max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">A totalidade do exemplo de c\u00f3digo pode ser encontrada no arquivo <\/span><a href=\"https:\/\/github.com\/couchbaselabs\/AnalyticsML\"><span style=\"font-weight: 400;\">Reposit\u00f3rio do GitHub.<\/span><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Ao executar o script Python do modelo mostrado acima, voc\u00ea dever\u00e1 obter o seguinte resultado:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12794\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/02\/python2.png\" alt=\"\" width=\"655\" height=\"365\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python2.png 655w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python2-300x167.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python2-20x11.png 20w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Voc\u00ea pode ler mais sobre as m\u00e9tricas do scikit-learn, como precis\u00e3o, recall, pontua\u00e7\u00e3o f1 e suporte <\/span><a href=\"https:\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.metrics.precision_recall_fscore_support.html\"><span style=\"font-weight: 400;\">aqui<\/span><\/a><span style=\"font-weight: 400;\">. Agora temos um modelo de aprendizado de m\u00e1quina funcional e com bom desempenho, totalmente treinado em Python.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Criando uma biblioteca Python<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Para fazer refer\u00eancia ao modelo de aprendizado de m\u00e1quina, voc\u00ea precisar\u00e1 criar uma biblioteca Python. Abaixo est\u00e1 a biblioteca para este exemplo espec\u00edfico:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12795\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/02\/python3.png\" alt=\"\" width=\"1600\" height=\"966\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python3.png 1600w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python3-300x181.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python3-1024x618.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python3-768x464.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python3-1536x927.png 1536w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python3-20x12.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python3-1320x797.png 1320w\" sizes=\"auto, (max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">H\u00e1 dois componentes principais da biblioteca:<\/span><\/p>\n<p><b>Construtor de modelos<\/b><span style=\"font-weight: 400;\">-Esse construtor cria um arquivo chamado <\/span><em><span style=\"font-weight: 400;\">modelo_de_sentimento<\/span><\/em><span style=\"font-weight: 400;\"> no <\/span><span style=\"font-weight: 400;\"><em>dutos<\/em> <\/span><span style=\"font-weight: 400;\">do nosso ambiente Jupyter.<\/span><\/p>\n<p><b>m\u00e9todo getSentiment<\/b><span style=\"font-weight: 400;\">-Esse m\u00e9todo prev\u00ea o sentimento do cliente associado ao par\u00e2metro (ou argumento) passado para ele.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Salve o arquivo como <\/span><i><span style=\"font-weight: 400;\">sentimento.py<\/span><\/i><span style=\"font-weight: 400;\"> dentro do <\/span><i><span style=\"font-weight: 400;\">dutos<\/span><\/i><span style=\"font-weight: 400;\"> com o arquivo <\/span><i><span style=\"font-weight: 400;\">modelo_de_sentimento<\/span><\/i><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Empacotamento e implanta\u00e7\u00e3o da biblioteca<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Essa \u00e9 uma etapa essencial para o que vir\u00e1 a seguir: desbloquear o poder das fun\u00e7\u00f5es definidas pelo usu\u00e1rio do Python! Preste aten\u00e7\u00e3o aos detalhes, pois ela depende mais da sintaxe do que qualquer outra. Certifique-se de ler atentamente a documenta\u00e7\u00e3o apropriada. Siga o link <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/analytics\/9_udf.html#external-functions\"><span style=\"font-weight: 400;\">para saber mais sobre fun\u00e7\u00f5es definidas pelo usu\u00e1rio<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Para empacotar o modelo e a biblioteca que criamos nas etapas anteriores, usaremos o utilit\u00e1rio shiv. Se o shiv ainda n\u00e3o estiver instalado, use o comando <\/span><i><span style=\"font-weight: 400;\">pip install shiv<\/span><\/i><i><span style=\"font-weight: 400;\"> (ou <\/span><\/i><i><span style=\"font-weight: 400;\">pip3 install shiv<\/span><\/i><span style=\"font-weight: 400;\"> dependendo de seu ambiente). Al\u00e9m disso, se voc\u00ea estiver interessado em ler a documenta\u00e7\u00e3o desse utilit\u00e1rio de linha de comando, poder\u00e1 encontr\u00e1-la <\/span><a href=\"https:\/\/shiv.readthedocs.io\/en\/latest\/\"><span style=\"font-weight: 400;\">aqui<\/span><\/a><span style=\"font-weight: 400;\">.\u00a0<\/span><\/p>\n<p><b>Etapas para empacotar o modelo:<\/b><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">Em seu laptop, empacote o modelo de sentimento e o c\u00f3digo do modelo. Isso o torna autoexecut\u00e1vel e remove todas as depend\u00eancias de biblioteca:<\/span><\/li>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><i><span style=\"font-weight: 400;\">shiv -site-packages pipelines\/ -o pipeline.pyz -platform manylinux1_x86_64 -python-version 39 -only-binary=:all: scikit-learn<\/span><\/i><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">-plataforma manylinux1_x86_64<\/span><span style=\"font-weight: 400;\"> s\u00f3 \u00e9 necess\u00e1rio quando se usa uma m\u00e1quina virtual com Linux.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Copie o pacote Python aut\u00f4nomo com as depend\u00eancias necess\u00e1rias para o servidor de an\u00e1lise:<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><i><span style=\"font-weight: 400;\">docker cp pipeline.pyz cb-analytics:\/tmp\/<\/span><\/i><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Acesse o shell do <\/span><span style=\"font-weight: 400;\">cb-analytics<\/span><span style=\"font-weight: 400;\"> Cont\u00eainer do Docker:<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">docker exec -it cb-analytics bash<\/span><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">No shell do Docker, v\u00e1 para o diret\u00f3rio <\/span><span style=\"font-weight: 400;\">tmp <\/span><span style=\"font-weight: 400;\">na pasta onde o arquivo zip est\u00e1 localizado e importe os dados necess\u00e1rios para os dois compartimentos:<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><i><span style=\"font-weight: 400;\">cd \/tmp<\/span><\/i><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><i><span style=\"font-weight: 400;\">curl -v -X POST -F \"data=@.\/pipeline.pyz\" -F \"type=python\" \"localhost:8095\/analytics\/library\/Default\/sentimentlibrary\" -u Administrator:password;<\/span><\/i><\/li>\n<\/ul>\n<\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">O sistema ser\u00e1 atualizado quando estiver conclu\u00eddo e ser\u00e1 bem-sucedido quando voc\u00ea vir essa resposta HTTP 200:<\/span><\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12796\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/02\/python4.png\" alt=\"\" width=\"814\" height=\"248\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python4.png 814w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python4-300x91.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python4-768x234.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python4-20x6.png 20w\" sizes=\"auto, (max-width: 814px) 100vw, 814px\" \/><\/p>\n<h4><span style=\"font-weight: 400;\">Importando o documento do bucket para an\u00e1lise pelo UDF<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">H\u00e1 duas etapas a serem seguidas em seu computador local e tr\u00eas comandos a serem executados na inst\u00e2ncia do Docker.<\/span><\/p>\n<p><b>M\u00e1quina local<\/b><\/p>\n<p><span style=\"font-weight: 400;\">0. Criar baldes <\/span><em><span style=\"font-weight: 400;\">filme<\/span><\/em><span style=\"font-weight: 400;\"> ou <\/span><em><span style=\"font-weight: 400;\">cr\u00edticas de filmes <\/span><\/em><span style=\"font-weight: 400;\">seja no <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-buckets\/create-bucket.html#create-bucket-using-couchbase-web-console\"><span style=\"font-weight: 400;\">console da Web<\/span><\/a><span style=\"font-weight: 400;\"> ou por meio do <\/span><em><a href=\"https:\/\/docs.couchbase.com\/server\/current\/cli\/cbcli\/couchbase-cli-bucket-create.html#examples\"><span style=\"font-weight: 400;\">couchbase-cli<\/span><\/a><\/em><span style=\"font-weight: 400;\"> comando<\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400;\">Executar: <\/span><span style=\"font-weight: 400;\"><em>docker cp rotten_tomatoes_critic_reviews.csv<\/em> <em>cb:\/tmp\/ <\/em><\/span>Esse arquivo ultrapassa o limite de 100 Mb do utilit\u00e1rio de importa\u00e7\u00e3o da GUI e precisa ser importado diretamente.<\/li>\n<\/ol>\n<p><b>Inst\u00e2ncia do Docker<\/b><\/p>\n<p><em><span style=\"font-weight: 400;\">2. docker exec -it cb bash<\/span><\/em><\/p>\n<p><em><span style=\"font-weight: 400;\">3. cbimport csv -infer-types -c https:\/\/localhost:8091 -u Administrator -p password -d 'file:\/\/rotten_tomatoes_critic_reviews.csv' -b 'movie_reviews' -scope-collection-exp \"_default._default\" -g \"%rotten_tomatoes_link%\"<\/span><\/em><\/p>\n<p><em><span style=\"font-weight: 400;\">4. cbimport csv -infer-types -c https:\/\/localhost:8091 -u Administrator -p password -d 'file:\/\/rotten_tomatoes_movies.csv' -b 'movies' -scope-collection-exp \"_default._default\" -g \"%rotten_tomatoes_link%\"<\/span><\/em><\/p>\n<p><span style=\"font-weight: 400;\">Voc\u00ea pode importar o \u00faltimo arquivo (<\/span><em><span style=\"font-weight: 400;\">rotten_tomatoes_movies.csv<\/span><\/em><span style=\"font-weight: 400;\">) na linha de comando, conforme mostrado acima, ou no <\/span><i><span style=\"font-weight: 400;\">Console da Web do Couchbase &gt; Documento &gt; Importar<\/span><\/i><span style=\"font-weight: 400;\"> do portal do Couchbase, conforme mostrado nesta captura de tela:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12797\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/02\/python5.png\" alt=\"\" width=\"1600\" height=\"545\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python5.png 1600w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python5-300x102.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python5-1024x349.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python5-768x262.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python5-1536x523.png 1536w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python5-20x7.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python5-1320x450.png 1320w\" sizes=\"auto, (max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Agora voc\u00ea tem documentos nos dois buckets e eles cont\u00eam a cr\u00edtica e os resumos dos filmes no Couchbase para executar a an\u00e1lise de sentimentos.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12798\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/02\/python6.png\" alt=\"\" width=\"715\" height=\"377\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python6.png 715w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python6-300x158.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/02\/python6-20x11.png 20w\" sizes=\"auto, (max-width: 715px) 100vw, 715px\" \/><\/p>\n<h4><span style=\"font-weight: 400;\">Grava\u00e7\u00e3o de UDFs<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">\u00c9 hora de escrever nossa pr\u00f3pria fun\u00e7\u00e3o definida pelo usu\u00e1rio no Couchbase Analytics. Se voc\u00ea precisar de uma atualiza\u00e7\u00e3o, aqui est\u00e1 um link para nossa documenta\u00e7\u00e3o sobre <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/analytics\/9_udf.html\"><span style=\"font-weight: 400;\">Fun\u00e7\u00f5es definidas pelo usu\u00e1rio<\/span><\/a><span style=\"font-weight: 400;\">. Consulte a biblioteca (o <\/span><em><span style=\"font-weight: 400;\">Modelo<\/span><\/em><span style=\"font-weight: 400;\"> e o construtor <\/span><em><span style=\"font-weight: 400;\">getSentiment <\/span><\/em><span style=\"font-weight: 400;\">) que criamos na Etapa 2 e depois carregamos no servidor do Analytics na Etapa 3. Eles agora s\u00e3o referenciados na seguinte fun\u00e7\u00e3o definida pelo usu\u00e1rio:<\/span><\/p>\n<pre class=\"\">CREATE ANALYTICS FUNCTION getReviewSentiment(text) AS \"sentiment\", \"Model.getSentiment\" \r\nAT sentimentlibrary;<\/pre>\n<p><span style=\"font-weight: 400;\">Crie o UDF do Analytics no mesmo local (<\/span><em><span style=\"font-weight: 400;\">biblioteca de sentimentos<\/span><\/em><span style=\"font-weight: 400;\">) conforme especificado no <\/span><span style=\"font-weight: 400;\">enrolar <\/span><span style=\"font-weight: 400;\">fun\u00e7\u00e3o.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Invocando os UDFs<\/span><\/h4>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Aproveitando os recursos do N1QL, agora podemos escrever consultas preditivas no Couchbase Analytics para obter insights avan\u00e7ados de nossos UDFs. Por baixo dos panos, ao invocar esse UDF, ele chama o <\/span><b>Modelo <\/b><span style=\"font-weight: 400;\">que itera sobre cada linha para fazer a an\u00e1lise de sentimento. A seguir, um exemplo b\u00e1sico de uma consulta desse tipo, mas as possibilidades s\u00e3o realmente infinitas.<\/span><\/p>\n<pre class=\"\">USE Default;\r\nSELECT getReviewSentiment(r.review_content) AS sentiment, COUNT(*) AS sentimentCount\r\nFROM movie_reviews r, movies m\r\nWHERE m.rotten_tomatoes_link = r.rotten_tomatoes_link\r\nGROUP BY getReviewSentiment(r.review_content)\r\nORDER BY sentimentCount DESC;<\/pre>\n<p><span style=\"font-weight: 400;\">Com essa consulta, voc\u00ea obter\u00e1 resultados como os seguintes:<\/span><\/p>\n<pre class=\"\">[\r\n{\r\n\"sentimentCount\": 10105,\r\n\"sentiment\": \"Fresh\"\r\n},\r\n{\r\n\"sentimentCount\": 7601,\r\n\"sentiment\": \"Rotten\"\r\n}\r\n]<\/pre>\n<p><span style=\"font-weight: 400;\">Agora temos uma contagem ordenada de sentimentos positivos, neutros e negativos, conforme definido por nosso modelo treinado.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Conclus\u00e3o<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Parab\u00e9ns, voc\u00ea acabou de configurar o ambiente necess\u00e1rio do Couchbase Server no Docker e executou com \u00eaxito sua primeira fun\u00e7\u00e3o definida pelo usu\u00e1rio no Couchbase Analytics. Como voc\u00ea pode ver, a integra\u00e7\u00e3o dos seus modelos Python ML com UDFs e o Couchbase Analytics promete ser uma maneira eficaz de extrair informa\u00e7\u00f5es valiosas dos seus dados sem comprometer o desempenho ou a efici\u00eancia.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Fique \u00e0 vontade para compartilhar d\u00favidas ou coment\u00e1rios nos coment\u00e1rios abaixo ou por meio de uma postagem em <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/pt\/forums\/\"><span style=\"font-weight: 400;\">F\u00f3runs do Couchbase<\/span><\/a><span style=\"font-weight: 400;\">. Mal podemos esperar para ver como voc\u00ea combinar\u00e1 o poder do ML e do NoSQL para sua empresa.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Se quiser saber mais sobre o Couchbase Analytics, assista \u00e0 nossa Sess\u00e3o de conex\u00e3o: <\/span><a href=\"https:\/\/www.youtube.com\/watch?v=nyHUKfTMKDQ\"><span style=\"font-weight: 400;\">Aprendizado de m\u00e1quina e NoSQL: UDFs em Python<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><iframe loading=\"lazy\" title=\"O aprendizado de m\u00e1quina encontra o NoSQL: UDFs em Python - CBConnect21\" width=\"900\" height=\"506\" src=\"https:\/\/www.youtube.com\/embed\/nyHUKfTMKDQ?feature=oembed&#038;enablejsapi=1&#038;origin=https:\/\/www.couchbase.com\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/p>\n<p><span style=\"font-weight: 400;\">Aqui est\u00e1 um resumo dos links e t\u00f3picos mencionados nesta postagem:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.couchbase.com\/blog\/pt\/ml-meets-nosql-integrating-python-user-defined-functions-with-n1ql-for-analytics\/\"><span style=\"font-weight: 400;\">Parte 1 - O ML encontra o NoSQL: Integra\u00e7\u00e3o de fun\u00e7\u00f5es definidas pelo usu\u00e1rio do Python com o N1QL para an\u00e1lise<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/github.com\/couchbaselabs\/AnalyticsML\"><span style=\"font-weight: 400;\">Reposit\u00f3rio do GitHub do Couchbase AnalyticsML<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.kaggle.com\/stefanoleone992\/rotten-tomatoes-movies-and-critic-reviews-dataset\"><span style=\"font-weight: 400;\">Conjunto de dados do Kaggle de avalia\u00e7\u00f5es do Rotten Tomatoes<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/docs.couchbase.com\/server\/current\/analytics\/9_udf.html\"><span style=\"font-weight: 400;\">Documenta\u00e7\u00e3o das fun\u00e7\u00f5es definidas pelo usu\u00e1rio do Couchbase<\/span><\/a><\/li>\n<\/ul>\n<p><b data-stringify-type=\"bold\">Agradecimentos<\/b><br \/>\nAgradecimentos a\u00a0<b data-stringify-type=\"bold\">Anuj Kothari,\u00a0<\/b>um estagi\u00e1rio de ver\u00e3o em gerenciamento de produtos do servi\u00e7o Couchbase Analytics, cujos esfor\u00e7os iniciais fizeram com que isso come\u00e7asse e sa\u00edsse do papel no ver\u00e3o passado. Agradecimentos a\u00a0<b data-stringify-type=\"bold\">Idris Motiwala<\/b>Gerente de produto principal do Couchbase Analytics Service e\u00a0<b data-stringify-type=\"bold\">Ian Maxon<\/b>engenheiro de software do Couchbase Analytics Service, por seu trabalho editorial para tornar este blog mais funcional.<\/p>","protected":false},"excerpt":{"rendered":"<p>With Couchbase 7.0 you&#8217;re now capable of allowing integration of Python UDFs with Couchbase Analytics. In Part 1 of this blog series, we covered the essentials for getting Couchbase and the Analytics for Machine Learning (ML) set up. ML has [&hellip;]<\/p>","protected":false},"author":79257,"featured_media":12627,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[2294,9139,2201],"tags":[2140,1725],"ppma_author":[9482],"class_list":["post-12792","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","category-python","category-tools-sdks","tag-machine-learning","tag-nosql-database"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.8 (Yoast SEO v25.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Leveraging your ML models with Couchbase Analytics User Defined Functions (UDF) - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"In this blog post we walk you though to show you how to apply external algorithms to data that is resident in Couchbase.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/pt\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Leveraging your ML models with Couchbase Analytics User Defined Functions (UDF)\" \/>\n<meta property=\"og:description\" content=\"In this blog post we walk you though to show you how to apply external algorithms to data that is resident in Couchbase.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/pt\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-16T16:34:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T04:25:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/simon-abrams-k_T9Zj3SE8k-unsplash-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1706\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Muk Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Muk Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/\"},\"author\":{\"name\":\"Muk Sreenivasan\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/b37fc76b5459210102cef15674423031\"},\"headline\":\"Leveraging your ML models with Couchbase Analytics User Defined Functions (UDF)\",\"datePublished\":\"2022-02-16T16:34:12+00:00\",\"dateModified\":\"2025-06-14T04:25:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/\"},\"wordCount\":1514,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/simon-abrams-k_T9Zj3SE8k-unsplash-scaled.jpg\",\"keywords\":[\"Machine Learning (ML)\",\"NoSQL Database\"],\"articleSection\":[\"Couchbase Analytics\",\"Python\",\"Tools &amp; SDKs\"],\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/\",\"name\":\"Leveraging your ML models with Couchbase Analytics User Defined Functions (UDF) - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/simon-abrams-k_T9Zj3SE8k-unsplash-scaled.jpg\",\"datePublished\":\"2022-02-16T16:34:12+00:00\",\"dateModified\":\"2025-06-14T04:25:06+00:00\",\"description\":\"In this blog post we walk you though to show you how to apply external algorithms to data that is resident in Couchbase.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/simon-abrams-k_T9Zj3SE8k-unsplash-scaled.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/simon-abrams-k_T9Zj3SE8k-unsplash-scaled.jpg\",\"width\":2560,\"height\":1706,\"caption\":\"Couchbase Capella 2 years!\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Leveraging your ML models with Couchbase Analytics User Defined Functions (UDF)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/b37fc76b5459210102cef15674423031\",\"name\":\"Muk Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/194f54236bbc53ba3b1b5550c654d008\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/muk_sreenivasan.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/muk_sreenivasan.png\",\"caption\":\"Muk Sreenivasan\"},\"url\":\"https:\/\/www.couchbase.com\/blog\/pt\/author\/muk-sreenivasan\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Leveraging your ML models with Couchbase Analytics User Defined Functions (UDF) - The Couchbase Blog","description":"Nesta postagem do blog, mostraremos a voc\u00ea como aplicar algoritmos externos a dados residentes no Couchbase.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/pt\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/","og_locale":"pt_BR","og_type":"article","og_title":"Leveraging your ML models with Couchbase Analytics User Defined Functions (UDF)","og_description":"In this blog post we walk you though to show you how to apply external algorithms to data that is resident in Couchbase.","og_url":"https:\/\/www.couchbase.com\/blog\/pt\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/","og_site_name":"The Couchbase Blog","article_published_time":"2022-02-16T16:34:12+00:00","article_modified_time":"2025-06-14T04:25:06+00:00","og_image":[{"width":2560,"height":1706,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/simon-abrams-k_T9Zj3SE8k-unsplash-scaled.jpg","type":"image\/jpeg"}],"author":"Muk Sreenivasan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Muk Sreenivasan","Est. reading time":"8 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/"},"author":{"name":"Muk Sreenivasan","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/b37fc76b5459210102cef15674423031"},"headline":"Leveraging your ML models with Couchbase Analytics User Defined Functions (UDF)","datePublished":"2022-02-16T16:34:12+00:00","dateModified":"2025-06-14T04:25:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/"},"wordCount":1514,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/simon-abrams-k_T9Zj3SE8k-unsplash-scaled.jpg","keywords":["Machine Learning (ML)","NoSQL Database"],"articleSection":["Couchbase Analytics","Python","Tools &amp; SDKs"],"inLanguage":"pt-BR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/","url":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/","name":"Leveraging your ML models with Couchbase Analytics User Defined Functions (UDF) - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/simon-abrams-k_T9Zj3SE8k-unsplash-scaled.jpg","datePublished":"2022-02-16T16:34:12+00:00","dateModified":"2025-06-14T04:25:06+00:00","description":"Nesta postagem do blog, mostraremos a voc\u00ea como aplicar algoritmos externos a dados residentes no Couchbase.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/simon-abrams-k_T9Zj3SE8k-unsplash-scaled.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/simon-abrams-k_T9Zj3SE8k-unsplash-scaled.jpg","width":2560,"height":1706,"caption":"Couchbase Capella 2 years!"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/leveraging-your-ml-models-with-couchbase-analytics-user-defined-functions-udf\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Leveraging your ML models with Couchbase Analytics User Defined Functions (UDF)"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"Blog do Couchbase","description":"Couchbase, o banco de dados NoSQL","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"Blog do Couchbase","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/b37fc76b5459210102cef15674423031","name":"Muk Sreenivasan","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/194f54236bbc53ba3b1b5550c654d008","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/muk_sreenivasan.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/muk_sreenivasan.png","caption":"Muk Sreenivasan"},"url":"https:\/\/www.couchbase.com\/blog\/pt\/author\/muk-sreenivasan\/"}]}},"authors":[{"term_id":9482,"user_id":79257,"is_guest":0,"slug":"muk-sreenivasan","display_name":"Muk Sreenivasan","avatar_url":{"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/muk_sreenivasan.png","url2x":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/03\/muk_sreenivasan.png"},"author_category":"","last_name":"Sreenivasan","first_name":"Muk","job_title":"","user_url":"","description":"Muk is a Senior Sales Engineer at Couchbase covering the west coast of the United States. He has over 20 years experience in product support, product development, product management and Sales. He lives and works in Silicon Valley."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/12792","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/users\/79257"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/comments?post=12792"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/12792\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media\/12627"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media?parent=12792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/categories?post=12792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/tags?post=12792"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/ppma_author?post=12792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}