<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Prasanth Mathesh on Medium]]></title>
        <description><![CDATA[Stories by Prasanth Mathesh on Medium]]></description>
        <link>https://medium.com/@prasanthmathesh?source=rss-6248afeb5d6b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tHUsZ00zxKFkJV-3ifPwHw.jpeg</url>
            <title>Stories by Prasanth Mathesh on Medium</title>
            <link>https://medium.com/@prasanthmathesh?source=rss-6248afeb5d6b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 01:21:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prasanthmathesh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Engineering the Agentic Enterprise: IT Architecture in Agentic Era]]></title>
            <link>https://medium.com/cloud-data-analytics/engineering-the-agentic-enterprise-it-architecture-in-agentic-era-3c93f5264383?source=rss-6248afeb5d6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c93f5264383</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Prasanth Mathesh]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 05:22:18 GMT</pubDate>
            <atom:updated>2026-03-29T15:24:02.582Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction:</strong></h3><p>As enterprises move toward more autonomy, agility, and intelligent automation, agentic architectures are quickly becoming a major shift in how IT systems are designed. These architectures rely on software agents that can understand context, make decisions, and act with purpose -powered largely by modern language models.</p><p>In my previous <a href="https://prasanthmathesh.medium.com/serverless-generative-ai-on-aws-an-overview-1d6c35a6bb98"><strong>blog</strong>,</a> I highlighted why solid data engineering and data architecture are essential for AI success. In this post, I’ll break down the basics of AI Agents,Ontology, how they may fit into enterprise IT in the near future, and the key challenges organizations will face as they adopt them.</p><h3><strong>Basics</strong></h3><p>Tokens:</p><ul><li>Tokens are the basic units of text that a Large Language Model reads and writes — usually pieces of words, whole words, or punctuation.</li><li>LLMs process text by breaking it into tokens, and the number of tokens determines cost, speed, and how much context the model can handle at once.</li></ul><p>Transformers:</p><p>Transformers are a neural network architecture that revolutionized modern AI. Their core strength lies in <strong>self‑attention</strong>, which allows the model to understand relationships between words (or tokens) regardless of their position. This makes them ideal for:</p><ul><li>Natural language understanding and generation</li><li>Code generation</li><li>Vision‑language tasks</li><li>Multimodal reasoning</li><li>Foundation models and agentic systems</li></ul><p>LLMs:</p><ul><li>Large Language Models are AI systems trained on massive amounts of text to understand and generate human‑like language.</li><li>They can perform tasks such as answering questions, summarizing content, reasoning, coding, and acting as the intelligence layer behind modern AI agents.</li><li>LLMs require far more tokens during training because they learn broad language patterns, deep reasoning, and cross‑domain knowledge, which demands massive and diverse datasets.</li><li>LLMs are usually pretrained on massive corpora, then fine-tuned for specific tasks (e.g., medical, legal, coding).</li></ul><p>SLMs:</p><ul><li>Small Language Models are fast, lightweight, and cost‑efficient, making them easy to deploy at the edge.</li><li>They’re well‑suited for embedded agents, microservices, and focused, domain‑specific tasks</li><li>SLMs need fewer tokens to train because they focus on narrower, domain‑specific tasks and smaller model sizes, allowing them to learn effectively from compact, curated datasets.</li><li>SLMs are often trained from scratch or fine-tuned on small datasets.</li></ul><p>AI Mesh</p><ul><li>AI Mesh uses the governed, connected, and real‑time data layer provided by Data Fabric/Data Mesh to give AI agents reliable access to operational and domain data — enabling them to automate workflows, make decisions, and power SaaS‑like intelligence across the enterprise.</li><li>It adds a coordination and reasoning layer on top of the data ecosystem, allowing multiple agents, models, and services to work together — turning enterprise IT systems into adaptive, AI‑driven operational platforms.</li></ul><h3>How AI Mesh Works for SLMs vs LLMs</h3><p><strong>For Small Language Models</strong></p><p>AI Mesh helps:</p><ul><li>Deploy models across edge devices , local machines, etc.</li><li>Route requests to the most efficient node</li><li>Enable real-time, low-power inference</li><li>Support modular updates (e.g., swapping out a domain-specific model)</li></ul><p><strong>For Large Language Models</strong></p><p>AI Mesh enables:</p><ul><li>Distributed training across multiple GPUs or TPUs</li><li>Scalable inference with load balancing</li><li>Federated learning across data silos</li><li>Integration with other multi modal AI services (vision, speech, etc.)</li></ul><h3>Agentic IT : Transformation Across Enterprise Data Functions</h3><h4><strong>Data Modelling and Architecture:</strong></h4><p>Modern Agentic BI platforms are evolving the semantic layer into something richer:</p><ul><li><strong>Ontology + Knowledge Graphs</strong>: Define relationships and meaning across entities. Building RAG systems on top of this ontology‑driven foundation is no longer optional, it’s becoming essential.</li><li><strong>Memory + LLM Orchestration</strong>: Help agents retain context and plan multi-step workflows.</li><li><strong>Governance + Guardrails</strong>: Ensure outputs align with business rules and security policies.</li></ul><p>This “agentic semantic layer” transforms raw data into <strong>actionable intelligence</strong> by giving agents the structure they need to think and act like domain experts.</p><p><strong>Example :</strong> LookML is a <strong>semantic modeling language</strong> used in Google Looker. It defines how raw data maps to business‑friendly metrics, dimensions, and relationships. Transformers can then query LookML‑modeled data for accurate, governed insights</p><p><strong>Best Fit</strong>: LLMs (Large Language Models)</p><p>Building and modelling a semantic layer requires deep reasoning, long‑context understanding, and multi‑step architectural thinking — all areas where LLMs outperform SLMs.</p><p>In a Nutshell:</p><ul><li><strong>Semantic layer </strong>standardizes business logic and ensures AI agents (or any consumers) operate on governed, consistent definitions across all data experiences.</li><li><strong>Semantic models</strong> encode the business logic — metrics, dimensions, and relationships — that AI agents rely on for accurate reasoning.</li><li><strong>Semantic context views</strong> provide domain‑specific, simplified entry points into the semantic layer, making it easier for AI agents to query data correctly</li></ul><h4><strong>Coding Agents:</strong></h4><p>Coding agents accelerate data engineering by generating, validating, and optimizing pipeline code, reducing manual effort and boosting development velocity</p><p>Best fit: LLMs (Large Language Models)</p><ul><li>Coding requires <strong>multi‑step reasoning</strong>, <strong>refactoring</strong>, <strong>architecture‑level understanding</strong>, and <strong>context stitching</strong> across files.</li><li>LLMs outperform SLMs in:</li><li>complex SQL generation</li><li>PySpark/Scala transformations</li><li>dbt model creation</li><li>pipeline orchestration logic</li><li>debugging multi‑file codebases</li></ul><p>SLMs struggle with long‑context reasoning and multi‑file dependencies. Small Language Models (SLMs) <em>can</em> act as coding agents — especially when designed for narrow, repetitive, and well-scoped tasks.</p><h4><strong>Test agents:</strong></h4><ul><li>Test agents automate validation across data pipelines, APIs, and applications by generating test cases, executing checks, and detecting anomalies with minimal human intervention.</li><li>They improve reliability and speed by continuously monitoring systems, enforcing quality standards, and rapidly surfacing defects before they impact production.</li></ul><p><strong>Best fit</strong>: SLMs + occasional LLM augmentation</p><ul><li>Most test generation and validation logic is <strong>structured</strong>, <strong>rule‑driven</strong>, and <strong>repeatable</strong> → ideal for SLMs.</li><li>For complex reasoning (e.g., generating edge‑case scenarios, interpreting ambiguous requirements), an LLM can be invoked selectively.</li></ul><h4><strong>Ops Agents:</strong></h4><ul><li>Ops agents continuously monitor data engineering environments for memory issues, dependency failures, environment drift, deployment errors, and infrastructure bottlenecks — surfacing early signals before pipelines or services degrade.</li><li>They autonomously remediate common operational tasks such as restarting services, reallocating compute, clearing temp storage, fixing environment configs, validating deployments, and enforcing DevOps standards, reducing engineering toil and keeping data platforms stable and compliant.</li></ul><p><strong>Best fit</strong>: SLMs (Small Language Models)</p><ul><li>Ops tasks are <strong>predictable, pattern‑based, and low‑latency</strong>.</li><li>SLMs excel at <strong>fast inference</strong>, <strong>on‑prem/edge deployment</strong>, and <strong>tight integration</strong> with infra tools.</li><li>They can run inside the platform (K8s, Airflow, Databricks jobs, Snowflake containers) with minimal cost.</li></ul><h4>Business Process Systems/System of Record (SoR):</h4><p><strong>SaaS :</strong></p><ul><li>Operational analytics is moving closer to core systems as SaaS platforms like Dynamics and Salesforce now hold 1–2 years of transactional data and reports.</li><li>This shift enables agents to directly access SaaS back‑end data, delivering faster, ad‑hoc operational insights without relying solely on traditional data analytics platforms</li></ul><p>For <strong>operational analytics</strong> directly on SaaS SoRs, the primary engine should be <strong>SLMs</strong>. <strong>LLMs </strong>act as <strong>escalation layers</strong> for complex reasoning, not the default</p><h3>Hybrid Agentic Enterprise AI Stack</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ysrhuj_JESw-R-IIqppBg.png" /><figcaption>Conceptual - Data/AI IT Solution Architecture</figcaption></figure><h4>1. Engagement Layer: Human-AI Interaction</h4><ul><li><strong>Multi-modal interfaces</strong>: Support for text, voice, and visual inputs to interact with agents.</li><li><strong>Agent orchestration</strong>: Use mini-agents or skill-specific agents to handle tasks with precision, reducing LLM overreach.</li><li><strong>SLM-first routing</strong>: Lightweight SLMs handle deterministic tasks (e.g., classification, summarization), escalating to LLMs only when needed.</li></ul><h4>2. Capability Layer: Intelligence &amp; Autonomy</h4><ul><li><strong>Hybrid reasoning</strong>: Combine SLMs for structured logic with LLMs for generative reasoning.</li><li><strong>Tool integration</strong>: Agents access external tools (SQL, APIs, vector search) via frameworks like Databricks Agent Bricks / Snowflake Cortex.</li><li><strong>Memory and planning</strong>: Agents maintain context, plan multi-step tasks, and adapt dynamically.</li><li><strong>Governance and observability</strong>: Built-in controls for monitoring agent behavior, accuracy, and compliance.</li></ul><h4>3. Data Layer: Foundation for Learning &amp; Trust</h4><ul><li><strong>Unified data access</strong>: Secure perimeter enables seamless access to structured and unstructured data with governance.</li><li><strong>Semantic indexing</strong>: Use vector embeddings and metadata tagging for fast retrieval and contextual grounding.</li><li><strong>Model training and fine-tuning</strong>: Databricks and Snowflake supports custom model development, including domain-specific SLMs and LLMs.</li><li><strong>Data lineage and auditability</strong>: Track how data flows through agents for transparency and compliance.</li></ul><h4>4. Core Principles for Agentic IT Success</h4><ul><li><strong>Composable architecture</strong>: Modular agents that can be reused and recombined.</li><li><strong>Change management</strong>: Success is 40% tech, 60% organizational alignment and adoption.</li><li><strong>Vendor ecosystem</strong>: Strategic partnerships across cloud, data, and AI platforms.</li><li><strong>Security-first design</strong>: Data residency, access controls, and model safety.</li></ul><h3>Agentic IT Challenges</h3><h4>Training Costs</h4><ul><li><strong>Compute Resources</strong></li><li>SLM: Can train on a single GPU or modest cloud setup</li><li>LLM: Requires hundreds to thousands of GPUs (often A100s or H100s)</li><li><strong>Training Time</strong></li><li>SLM: Hours to days</li><li>LLM: Weeks to months</li><li><strong>Cost Estimate</strong></li><li>SLM: Thousands to tens of thousands of dollars</li><li>LLM: Millions to tens of millions of dollars</li><li><strong>Energy Consumption</strong></li><li>SLM: Relatively low</li><li>LLM: Extremely high (comparable to powering small towns)</li></ul><h4>Environmental &amp; Energy Security Risks</h4><ul><li>Very high electricity usage from large AI models drives major carbon emissions and heavy cooling demands in data centers.</li><li>AI driven energy intensity is becoming an Energy Security and National Security concern for many countries.</li><li>Electricity can’t be stored and must travel long distances, and since we’re far from Kardashev‑Type II civilization energy capabilities, data centers will continue depending on terrestrial power. Sustainable operation is placing them in colder regions ( Northern USA, Canada) or near colder and stable energy basins (Athabasca) to manage heat and reduce transmission strain.</li><li>AI infrastructure depends on rare earth minerals for advanced chips, creating additional geopolitical and supply‑chain pressures.</li></ul><h4>Opex Advantage of Agent‑Driven IT</h4><ul><li>Agent‑based IT operations should operate at a materially lower Opex than human‑driven models.</li></ul><p>Databricks and Snowflake have spent years developing technologies that tackle core LLM challenges and strengthen their Data and AI ecosystems.</p><ul><li><strong>Databricks Agent Bricks</strong> handles agent development , orchestration serverless compute, domain‑tuned models etc.</li><li><strong>Snowflake Intelligence</strong> provides secure data access, Agent Development, model deployment , agent hosting etc.</li></ul><h3>Conclusion:</h3><p>Ecosystem Strength will be the real driver of AI Success. The future of enterprise AI won’t be defined by choosing between LLMs and SLMs. Real success comes from building a hybrid , strong ecosystem, robust infrastructure, clear governance, and broad organizational adoption. When these foundations are in place, LLMs and SLMs naturally complement each other, forming a hybrid intelligence layer that powers everything from autonomous IT to smarter customer experiences. It’s not about model size; it’s about strategic alignment and the strength of the ecosystem that surrounds them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c93f5264383" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloud-data-analytics/engineering-the-agentic-enterprise-it-architecture-in-agentic-era-3c93f5264383">Engineering the Agentic Enterprise: IT Architecture in Agentic Era</a> was originally published in <a href="https://medium.com/cloud-data-analytics">Cloud Data and Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks DLT and AWS Data Analytics Services for Seamless Serverless Streaming Dashboards / Data…]]></title>
            <link>https://medium.com/cloud-data-analytics/dlt-aws-databricks-afcbd0c4229a?source=rss-6248afeb5d6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/afcbd0c4229a</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Prasanth Mathesh]]></dc:creator>
            <pubDate>Wed, 08 Jan 2025 20:23:00 GMT</pubDate>
            <atom:updated>2026-02-11T01:00:31.485Z</atom:updated>
            <content:encoded><![CDATA[<h3>Databricks DLT and AWS Data Analytics Services for Seamless Serverless Streaming Dashboards / Data Apps</h3><p>Kappa Architecture, Streaming Table, Delta Live Table, AWS MSK, AWS Kinesis, Databricks Data Apps, Unity Catalog, SQL Warehouse</p><h3>Introduction</h3><p>The Databricks Lakehouse Architecture provides robust support for building Data Vault, Dimensional Modelling, and 3NF (Data Warehouse) architectures, seamlessly implementing Lambda and Kappa data engineering design patterns. While Kappa architecture presents a few bottlenecks compared to Lambda, Databricks offers excellent solutions to address these challenges. In this blog, we will explore how the combination of Databricks Streaming Delta Live Tables, Unity Catalog, and SQL Warehouse can effectively solve streaming architecture challenges.</p><h3><strong>Overview</strong></h3><h4>Kappa Architecture</h4><p>Kappa Architecture focuses on using a unified code base and technology stack for both streaming and batch data pipelines. Unlike Lambda Architecture, it employs a single serving/speed layer to handle both types of data processing.</p><h4>Delta Live Tables</h4><p>Based on Apache Spark, DLT simplifies the process of building and managing pipelines by defining queries to build streaming tables, rules for state management, deduplication.</p><h4>Unity Catalog</h4><p>Empowers data utilization across the organization by leveraging a data asset catalog, discovery features, and data lineage. It also facilitates data governance with fine-grained data access control, audit logs, and other essential features.</p><h4>Serverless SQL Warehouse</h4><p>Seamless Integrations with BI applications, scalable query engine, enables team collaboration by enabling Data Analysts to share their queries and results.</p><h3>Challenges in Streaming Kappa Architecture</h3><blockquote>Batch Data Sources</blockquote><blockquote>Costly reprocessing</blockquote><blockquote>Late arriving dimensions/events</blockquote><blockquote>Duplicate Transactions</blockquote><blockquote>Data Quality</blockquote><h3><strong>High Level Solution</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttuBBQrnqtFtN6pFZUs2WQ.jpeg" /><figcaption>Streaming Pipeline &amp; Dashboard</figcaption></figure><h4>Ingestion Layer</h4><p><strong>Real-Time Ingestion</strong>: Streaming sources often produce very small sized, high-velocity messages with variable spikes over short intervals based on activity. AWS provides various serverless services that can dynamically scale the stream readers based on incoming messages/files.</p><p>Serverless Kinesis Data Streams can be directly read by the DLT (Data Lake Table) pipeline and ingested into a Raw Delta Streaming table. This approach is ideal for semi-structured and binary data formats, as well as small volume files.</p><p><strong>Continuous File Ingestion</strong>: In the event of continuous file arrivals, files can be uploaded to S3 and ingested into the Raw Delta Streaming table using Autoloader. Kinesis Firehose too good option based on the use cases like combining small messages in to file etc. Unity Catalog External Volume facilitates data transfer from external applications.</p><p><strong>Unity Catalog External Volumes:</strong> Applies Data Governance to cloud storage, enabling third-party applications to securely share data via AWS S3. Databricks can then load this data using Autoloader, provided that the S3 Bucket ACLs and Storage Credentials are properly configured. COPY INTO and AUTO LOADER can be configured on UC volumes.</p><h4>Transformation Layer</h4><p><strong>DLT Stateful Streaming</strong>: Instead of using Spark Structured Streaming for incremental data processing, DLT (Data Lake Table) pipelines can be leveraged within a Medallion/Lakehouse Architecture. DLT expectations can be applied across all three layers:</p><ul><li><strong>Raw Layer</strong>: Preferred for row-level checks.</li><li><strong>Silver Layer</strong>: Suitable for late-arriving dimension checks.</li><li><strong>Gold Layer</strong>: Ideal for business aggregate metric checks.</li></ul><p><strong>Stateful Streaming:</strong> Watermarking enables effective duplicate and late arrival processing. Session window tracks events and breaks session aggregates when events stop occurring for a specific interval. By applying a larger watermark window and smaller aggregation window, one can manage late arrivals effectively in curation layer.</p><h4>Consumption</h4><p>Computation Layer encompasses various application like BI tools, AI/BI Dashboard a Databricks native Generative BI Dashboard and Data Apps.</p><p>Databricks Data Apps, currently in preview, enable teams to publish Data Quality metrics and Data Governance reports. With the increasing trend of enterprise applications being built on the cloud in recent years, data apps will play a critical role in delivering processed data through single-page/client-side applications in a Realtime manner.</p><h3>Gist</h3><h4><strong>Bronze</strong></h4><pre>@dlt.table(table_properties={&#39;quality&#39;: &#39;bronze&#39;,&#39;delta.enableChangeDataFeed&#39;: &#39;true&#39;})<br>@dlt.expect(&quot;valid_customer_age&quot;, &quot;Age BETWEEN 0 AND 110&quot;)<br>def customers_bronze():<br>  df =  (<br>    spark.readStream.format(&quot;cloudFiles&quot;)<br>      .option(&quot;cloudFiles.format&quot;, &quot;csv&quot;)<br>      .load(&quot;/Volumes/dltstreamingmain/dlt-streaming-external/incoming/customers/&quot;)<br>  )<br>  df_renamed_column = df.withColumn(&quot;bronze_insert_time&quot;, current_timestamp())<br>  return df_renamed_column<br><br><br>@dlt.table(table_properties={&#39;quality&#39;: &#39;bronze&#39;,&#39;delta.enableChangeDataFeed&#39;: &#39;true&#39;})<br>def sales_bronze():<br>  df =  (<br>    spark.readStream.format(&quot;cloudFiles&quot;)<br>      .option(&quot;cloudFiles.format&quot;, &quot;csv&quot;)<br>      .load(&quot;/Volumes/dltstreamingmain/dlt-streaming-external/incoming/sales/&quot;)<br>  )<br>  df_renamed_column =  df_renamed_column = df.withColumn(&quot;bronze_insert_time&quot;, current_timestamp()).withColumn(&quot;event_origin_timestamp&quot;, unix_timestamp(&quot;event_time&quot;, &quot;yyyy-MM-dd HH:mm:ss&quot;).cast(TimestampType()))<br>  return df_renamed_column</pre><p>Bronze with Duplicates</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7vxPm95l5ZjBprMJgcgvcg.png" /></figure><p>The watermarking and drop duplicates created Silver Table without Duplicates.</p><h4><strong>Copy INTO</strong></h4><pre>%sql<br>COPY INTO dltstreamingmain.dltstreamingmain.customers<br>FROM &#39;/Volumes/dltstreamingmain/dlt-streaming-external/incoming/&#39;<br>FILEFORMAT = CSV<br>FORMAT_OPTIONS (&#39;header&#39; = &#39;true&#39;)<br>COPY_OPTIONS (&#39;mergeSchema&#39; = &#39;true&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*BCZEaD3q1Ug7QwrIwAULiA.png" /></figure><p>The “copy into” function is idempotent, ensuring that processed files aren’t loaded multiple times. Since streaming APIs/Sources can retry messages for failed actions, there’s a risk of duplicate files. This feature effectively prevents such issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*3obG8KY1l5xqyiS4WrhMAA.png" /></figure><h4><strong>Silver</strong></h4><pre>import dlt<br>from pyspark.sql.functions import col, expr<br><br>dlt.create_streaming_table(&quot;customers_silver&quot;)<br>dlt.expect_or_drop(&quot;valid_customer_age&quot;, &quot;Age BETWEEN 0 AND 110&quot;)<br>dlt.apply_changes(<br>  target = &quot;customers_silver&quot;,<br>  source = &quot;customers_bronze&quot;,<br>  keys = [&quot;CustomerID&quot;],<br>  sequence_by = col(&quot;bronze_insert_time&quot;),<br>  except_column_list = [&quot;bronze_insert_time&quot;,&quot;_rescued_data&quot;],<br>  stored_as_scd_type = &quot;2&quot;<br>)<br><br>@dlt.table(<br>   schema=&quot;&quot;&quot;<br>     event_origin_timestamp timestamp,<br>     productid string,<br>     orderid string,<br>     txn_channel string,<br>     customerid string,<br>     product string,<br>     qty string,<br>     price string,<br>     total_sales double,<br>     silver_insert_time timestamp<br>    &quot;&quot;&quot;)<br>def sales_silver():<br>  df = dlt.read_stream(&quot;sales_bronze&quot;).withWatermark(&quot;event_origin_timestamp&quot;, &quot;1 minutes&quot;).dropDuplicatesWithinWatermark([&quot;customerid&quot;, &quot;productid&quot;]) \<br>                  .withColumn(&quot;total_sales&quot;, col(&quot;qty&quot;) * col(&quot;price&quot; )).withColumn(&quot;silver_insert_time&quot;, current_timestamp()) \<br>                  .select(&quot;*&quot;) \<br>                  .drop(&quot;_rescued_data&quot;,&quot;bronze_insert_time&quot;,&quot;event_time&quot;)<br>                  <br>  return df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j6N7BN_kCVJMDMCfo8eLUA.png" /></figure><p><strong>Late Arriving Dimensions</strong></p><p>Constraint Check on Dimension table. Left Join and Null check on Dimension Key also an alternate option.</p><pre>CONSTRAINT fk_customer_id FOREIGN KEY (customerid) REFERENCES dltstreamingmain.dltstreamingmain.customers_silver(CustomerID)</pre><h3><strong>Gold</strong></h3><h4>DLT Materialized View — Gold Layer</h4><pre>import dlt<br>from pyspark.sql.functions import col<br><br>@dlt.table(table_properties={&#39;quality&#39;: &#39;gold&#39;, &#39;delta.columnMapping.mode&#39;: &#39;name&#39;, &#39;delta.minReaderVersion&#39;: &#39;3&#39;, &#39;delta.minWriterVersion&#39;: &#39;7&#39;})<br>def realtime_sales_by_product():<br>    return (spark.read.table(&quot;dltstreamingmain.dltstreamingmain.sales_silver&quot;)<br>      .select(&quot;hour&quot;,&quot;minute&quot;,&quot;product&quot;, &quot;total_sales&quot;)<br>      .groupBy(&quot;hour&quot;,&quot;minute&quot;,&quot;product&quot;)<br>      .sum(&quot;total_sales&quot;)<br>    )</pre><p>Aggregate Query on silver Table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*5bGR3JZFzqBLmLVzxMOUGg.png" /></figure><p>Materialized View — Gold Layer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*qrcjgBp7rLsUgPO_1tJWyA.png" /></figure><p>Materialized View Refresh</p><pre>REFRESH &quot;dltstreamingmain.dltstreaminggold.realtime_sales_by_product&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*4_fslG6GpHIRjwdHN3fyuQ.png" /></figure><h4>Streaming Table</h4><pre>@dlt.table(table_properties={&#39;quality&#39;: &#39;gold&#39;, &#39;delta.columnMapping.mode&#39;: &#39;name&#39;, &#39;delta.minReaderVersion&#39;: &#39;3&#39;, &#39;delta.minWriterVersion&#39;: &#39;7&#39;})<br>def realtime_sales_by_product_table():<br>   return (<br>      dlt.read_stream(&quot;dltstreamingmain.dltstreamingmain.sales_silver&quot;)<br>      .withWatermark(&quot;event_origin_timestamp&quot;, &quot;3 minutes&quot;)<br>      .groupBy(window(&quot;event_origin_timestamp&quot;, &quot;5 minutes&quot;),&quot;product&quot;,&quot;hour&quot;,&quot;minute&quot;)<br>      .agg(sum(&quot;total_sales&quot;).alias(&quot;product_sales_by_minutes&quot;))<br>    )</pre><pre>CREATE OR REFRESH STREAMING TABLE realtime_sales_by_product_table<br>AS SELECT<br>  product, hour, minute, sum(total_sales) as total_sales<br>FROM STREAM<br>  (dltstreamingmain.dltstreamingmain.sales_silver)<br>WATERMARK<br>  event_origin_timestamp DELAY OF INTERVAL 3 MINUTES<br>GROUP BY<br>  product, hour, minute, window(event_origin_timestamp, &quot;5 minutes&quot;)</pre><p>Streaming Table — Gold</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*mR7MbLqzcrVAnE-gFBWWnQ.png" /><figcaption>Streaming Table Silver</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*LwQaNOMXCsy-W21VSVhuiQ.png" /><figcaption>Streaming Table Gold</figcaption></figure><p>After receiving the silver transactions, the windowed aggregates were updated in streaming append mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*VzqkTC_cfXwy1gxOvy6UYQ.png" /><figcaption>DLT Streaming Pipeline</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*7XZ56I0__JtnuQNqnzG3ug.png" /></figure><h3>Data Apps</h3><p>There are several patterns for building Data Bricks Data Apps:</p><ul><li>As outlined in my previous blog on <a href="https://medium.com/cloud-data-analytics/serverless-full-stack-data-analytics-engineering-on-aws-cloud-26cb65875632"><strong>serverless full stack data analytics</strong></a>, streaming data sources can be efficiently aggregated and stored in DynamoDB. For visualization, either AWS native applications or Databricks Apps can be utilized, achieving latency as low as 1–2 seconds.</li><li>Similar to Apache Flink, Apache Spark has now merged <a href="https://github.com/apache/spark/pull/47933">PR #47933</a>, introducing support for ListState and ValueState. With the Databricks SDK and APIs, developers can asynchronously access state values from state stores in non-DLT stateful streaming tables and relay aggregated metrics downstream with latencies as low as a few seconds. However, despite its low-latency capabilities, this architectural pattern is generally not recommended.</li><li>Data streams from Kinesis or other message brokers like Kafka can be transformed and routed to either Kafka or Kinesis for persistence, and visualized through the UI with sub-second latency. Delta Table storage, however, should be avoided for real-time operational reporting where sub-second latency is required.</li></ul><h3><strong>Conclusion</strong></h3><p>Delta Live Tables (DLT), built on Spark Structured Streaming, offers powerful features such as monitoring and error handling, data quality enforcement, and incremental data processing in a serverless environment. DLT manages checkpointing and state automatically, allowing users to refresh only the failed tables. This significantly accelerates the development of scalable streaming pipelines compared to managed streaming services. Furthermore, DLT’s support for streaming aggregates and state stores enables the creation of streaming dashboards within the AWS Databricks ecosystem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afcbd0c4229a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloud-data-analytics/dlt-aws-databricks-afcbd0c4229a">Databricks DLT and AWS Data Analytics Services for Seamless Serverless Streaming Dashboards / Data…</a> was originally published in <a href="https://medium.com/cloud-data-analytics">Cloud Data and Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Generative AI on AWS- An Overview]]></title>
            <link>https://aws.plainenglish.io/serverless-generative-ai-on-aws-an-overview-1d6c35a6bb98?source=rss-6248afeb5d6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d6c35a6bb98</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Prasanth Mathesh]]></dc:creator>
            <pubDate>Sun, 31 Mar 2024 14:23:07 GMT</pubDate>
            <atom:updated>2025-12-20T20:15:46.520Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Generative AI can be adopted in a wide range of industries unlike Blockchain that was very specific to financial and supply chain domain. Last year, hyper scalers rolled out native services for Generative AI use cases, specifically from AWS was Amazon Bedrock. In this article, let us see an overview about the Gen AI specific AWS services and how one can build a serverless application for Generative AI using them.</p><h3><strong>AWS Services</strong></h3><p><strong>Amazon Bedrock: </strong>It<strong> </strong>is a new service specifically designed for building and scaling generative AI applications.</p><p>With <strong>Amazon Bedrock</strong>, you can:</p><ul><li>Access leading <strong>foundation models</strong> (such as Claude 3 Haiku) that serve as the basis for generative AI.</li><li>Customize the foundation models with your own data.</li><li>Benefit from enterprise-grade security, privacy and responsible AI features.</li><li><strong>Claude 3 Haiku</strong> is one of the foundation models available on <strong>Amazon Bedrock</strong>. It is designed to generate poetic and concise text, making it ideal for creative applications.</li></ul><p><strong>Amazon EC2 P5 instances</strong>: These GPU-based instances provide high performance for training models.</p><p><strong>AWS Trainium and AWS Inferentia</strong>: Purpose-built accelerators for efficient inference.</p><p><strong>Amazon SageMaker JumpStart’s ML Hub</strong> to accelerate your model development.</p><p>The developer’s responsibility is to build and deploy the model. For other task like LLM Ops, the developer need not create any custom code, as AWS has ready to use services.</p><p>The key services to complete an AWS based serverless Generative AI architecture are:</p><ol><li>Serverless Compute: AWS Lambda, allows us to run code in response to events without managing servers.</li><li>Generative AI Models: Amazon Bedrock provides access to foundation models from Amazon and select third-party providers via a simple API. These models serve as the building blocks for generative AI applications.</li><li>API Endpoint Creation: API endpoint that accepts POST requests. For example, you can send a POST request to an Generative AI endpoint. For this, AWS API Gateway will be a good choice.</li><li>Response Generation: When you send a prompt, Amazon Bedrock generates a response. AWS Lambda can be invoked via API Gateway and it can fetch response from the End Point.</li></ol><p>High Level Solution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*knv_-warB1lKJgQyFAm5bQ.jpeg" /><figcaption>Serverless LLM</figcaption></figure><p>In my previous posts, I have explained how to provision API gateway, set up end point etc. This is in line with those except that the target endpoint which will interact with the AWS Bedrock Agents. The code snippet to invoke a titan text model is given below:</p><pre>bedrock_client = session.client(service_name=&quot;bedrock&quot;,config=retry_config,**client_kwargs )<br>prompt  = &quot;can you get me the previous day sales&quot;<br>body = json.dumps({&quot;inputText&quot;: prompt})<br>modelId = &quot;amazon.titan-tg1-large&quot;  <br>accept = &quot;application/json&quot;<br>contentType = &quot;application/json&quot;<br>response = bedrock_client.invoke_model_with_response_stream(<br>    body=body, modelId=modelId, accept=accept, contentType=contentType<br>)</pre><p>Detailed Reference:</p><p><a href="https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-text.html">Amazon Titan Text models</a></p><p>When working with InvokeModelWithResponseStream, the response is streamed—so it&#39;s important to account for this behavior when designing the application layer.Stream processing technologies such as Apache Flink and Apache Spark are increasingly vital for tracking and interpreting the states of Generative AI agents in real time manner</p><h3>Conclusion</h3><p>With Amazon Bedrock, there’s no longer a need to provision capacity, manage infrastructure, or write custom code — prompt engineering and related tasks are seamlessly handled. Developers simply link a knowledge base to the agent, enabling end users to interact with the model effectively. Data Engineering and Architecture will be crucial in shaping data models and curating training datasets. Foundational models using AWS Bedrock, along with fine-tuning frameworks such as the SFT Trainer, are poised to integrate into existing Data &amp; AI departments and customer-facing SaaS applications.</p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏️<strong>️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d6c35a6bb98" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/serverless-generative-ai-on-aws-an-overview-1d6c35a6bb98">Serverless Generative AI on AWS- An Overview</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Full Stack Data Analytics Engineering on AWS Cloud]]></title>
            <link>https://medium.com/cloud-data-analytics/serverless-full-stack-data-analytics-engineering-on-aws-cloud-26cb65875632?source=rss-6248afeb5d6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/26cb65875632</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Prasanth Mathesh]]></dc:creator>
            <pubDate>Sat, 25 Mar 2023 01:41:40 GMT</pubDate>
            <atom:updated>2023-03-25T01:41:40.346Z</atom:updated>
            <content:encoded><![CDATA[<h4>Serverless Full Stack Development for the modern data analytics</h4><h3>Overview</h3><p>Full Stack Developer is the one who does both client side and server side development for mobile and web applications. In data domain, full stack engineer performs similar kind of job duties that involves full ownership from ingesting data from sources till publishing data with consumers. The full stack data engineering is trending skillset who performs data analysis, SQL scripting, ETL/ELT programming, data model design, workload orchestration, visualization etc.</p><p>In some cases , Cloud Full Stack Data Analytics engineer responsibilities will add more like provision data infra, dataops, devops, etc. The full stack development and full stack data analytics are two different domain and only area they intersect is the datastore. The backend of an full stack web/mobile application can be upstream source or downstream consumer. But there is another layer in full stack data analytics that needs full stack dev engineering. That is modern visualization stack.</p><p>Most of BI/Visualization low code/no code SaaS products were built using full stack technologies like java scripts etc. In this first part article, we will see the need of full stack development in analytics department and how it can be developed and integrated within the data analytics application itself in a server less manner.</p><h3><strong>Embedded Analytics</strong></h3><p>The metrics displayed in dashboards were output of heavy lifting done in data processing layer. GB’s of data are processed and finally shared with semantic layer for building self service analytics, interactive dashboards. There are cases where business need to embed your analytical metrics in to the web application. These kind are metrics are called embedded analytics and often come with minimal filters.</p><p>These kind of implementations need end to end full stack development that both client and server side programming using angular, react js frameworks and mobile devices are involved that it comes with another set of tech stacks etc.</p><p>The modern data stack has evolved and its catching up well to have embedded web/mobile analytics. AWS QuickSight etc. supports low code embedded analytics and SaaS platforms like snowflake and data bricks has their own dashboards capability but they are not shareable to with web/mobile applications.</p><h3><strong>Embedded Analytics using AWS Amplify</strong></h3><p>AWS Amplify lets full stack developers to host their server less backend for the front ends. The Amplify Studio has features to build front end UI with a minimal effort. The JavaScript modules that supports the Charts, Graphs like D3.JS, Chart.JS can be used along with popular frameworks like react to the build custom dashboards using AWS Amplify.</p><p>The periodic data refresh for the back end data stores can be performed by using continuous data engineering pipelines within AWS cloud. The payload size plays a pivotal role for providing low latency customer dashboards. Thus, one has to choose right web framework and data model according to the traverse pattern of front end dashboards.</p><h3><strong>Architecture</strong></h3><p>The below diagram depicts end to end flow for embedding analytics with in any business applications, products, websites or portal. There is no additional BI tool or licensing involved for a department or organization that rely on static dashboards with basic filters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*AhYEw4Y0KFyxhmQiq_6LsA.png" /><figcaption>Embedded Data Analytics</figcaption></figure><p>The data engineering flow process the raw data in to Aggregates suitable for business strategy decision, measuring KPIs etc. The processed data is made available for business users both in real time and batch intervals and AppSync is the integration layer to share data with the front end applications in real time manner.</p><h3><strong>Conclusion</strong></h3><p>In this article, we have seen how we can use AWS Amplify within the analytics department of an organization. Due to complexity of technical stack, full stack development is kept as separate product team and often they are not owned by data engineering or analytics application team. AWS Amplify simplified the process prototyping and development of embedded analytical dashboards for data analytics engineering team. Amplify will help data teams to have custom built dashboards wider adoption among the data analytics user cases. In the next article, I will describe about how an enriched can be store and visualized using the AWS Amplify.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26cb65875632" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloud-data-analytics/serverless-full-stack-data-analytics-engineering-on-aws-cloud-26cb65875632">Serverless Full Stack Data Analytics Engineering on AWS Cloud</a> was originally published in <a href="https://medium.com/cloud-data-analytics">Cloud Data and Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon SQS and serverless DataEngineering workloads]]></title>
            <link>https://medium.com/cloud-data-analytics/amazon-sqs-and-serverless-dataengineering-workloads-7a538981ae70?source=rss-6248afeb5d6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a538981ae70</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[sqs]]></category>
            <category><![CDATA[data-anlytics]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Prasanth Mathesh]]></dc:creator>
            <pubDate>Sat, 25 Mar 2023 01:40:05 GMT</pubDate>
            <atom:updated>2023-03-25T01:40:05.350Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Overview</strong></h3><p>Amazon SQS provides fully managed message queuing for microservices, distributed systems, and serverless applications. Amazon SQS is one of the earliest services launched by Amazon and still widely used by many organizations,and it forms one of the core services of Saas / PaaS products that were built on top of the AWS cloud.</p><p>Data engineering workloads, especially with batch processing pipelines, where the flow of data processes will be orchestrated through any scheduling tool, AWS services like step functions, etc. A variety of use cases exist in the microservices architecture for AWS SQS but when it comes to data engineering, SQS is commonly used to publish messages with dynamic configurations that in turn trigger consumers to scale/parallelize workloads based on the SQS message data. The reason is that SQS by default, doesn’t handle messages &gt; 256KB.</p><p>Not all SaaS applications support bulk load or query due to API rate limits, performance factors, and so on. In an event-driven data architecture, especially when producers and consumers are SaaS applications, cloud web apps, etc., event ingestion is done using AWS AppFlow, Kinesis, or custom batch query processes.</p><p>If any SaaS is customizable, then the team can develop their own API using the AWS SDK to support ingestions and queries. There are cases where GBs of processed data have to be uploaded in bulk mode to a SaaS or Cloud Web Apps datastore in less than a minute interval. Below are the few scenarios that can be used in serverless event-driven data architectures.</p><h3>DataEngineering Workload</h3><p>SQS can be used to receive large payloads with the help of the extended client library. This feature has been in place since 2015 but is less commonly used in data engineering workloads. The AWS SDK extended SQS client library can be used to process up to 2 GB of data using S3 object storage. The producers of SQS can write messages &gt; 256KB in S3 and publish metadata in SQS, and SQS consumers can read and process the data. After the data processing is complete, write the data to the target object store or share it via API using any SQS message consumer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*4bEaATnpsFHgB_6ibbdF3w.jpeg" /><figcaption>SQS Process Flow</figcaption></figure><p>Consider an organisation that is using a customizable SaaS that was built using AWS services. The extended Java client library can be leveraged when a user needs to upload documents &gt; 256KB or an event is triggered for user action. These events can be used for building a decoupled data engineering workload that requires document parsing or tagging using services like AWS Textract, AWS Glue, or Serverless EMR. Using the DataSourceRegister Spark API, Spark structured streaming can be used as an SQS consumer for any high volume. The processed data can be shared with a webapp or SaaS using microservices or loaded into OLAP or OLTP services.</p><p>Multipart files of less than 2GB can be written into S3 using SQL unload and SQS consumers like AWS Lambda , AWS Glue, etc. can be invoked to write the processed files into target SaaS object stores in a concurrent manner provided the SaaS application supports the bulk load API.</p><h3><strong>Limitations</strong></h3><p>Unlike kafka, SQS can’t support non-ASCII characters like emojis. There is limited support for Unicode characters in the SQS service. So one has to consider the type of message and the complexity of transformation/aggregation, message retention period etc. before deciding on the type and need of message brokers for data engineering workloads.</p><h3><strong>Conclusion</strong></h3><p>Typically, it’s a common design pattern to have MQs, Kafka as message brokers, but Amazon SQS can be leveraged too for building loosely coupled data engineering pipelines for data generated by SaaS applications. The serverless AWS services are inherently scalable, and SQS can help to achieve parallelism of data processing in an event-driven data architecture without the need for any additional technical stack.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a538981ae70" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloud-data-analytics/amazon-sqs-and-serverless-dataengineering-workloads-7a538981ae70">Amazon SQS and serverless DataEngineering workloads</a> was originally published in <a href="https://medium.com/cloud-data-analytics">Cloud Data and Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Train, Deploy and Predict Cost-Effective ML Models in AWS Cloud]]></title>
            <link>https://aws.plainenglish.io/train-deploy-and-predict-cost-effective-ml-models-in-aws-cloud-789b43d33e4e?source=rss-6248afeb5d6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/789b43d33e4e</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Prasanth Mathesh]]></dc:creator>
            <pubDate>Sun, 19 Sep 2021 11:55:52 GMT</pubDate>
            <atom:updated>2021-09-19T11:55:52.367Z</atom:updated>
            <content:encoded><![CDATA[<h4>Serverless Amazon SageMaker Real-Time ML Inference</h4><h3>Introduction</h3><p>Amazon SageMaker is a fully managed service that enables data scientists and ML engineers to quickly create, train and deploy models and ML pipelines in an easily scalable and cost-effective way. The SageMaker was launched around Nov 2017 and I had a chance to get to know about inbuilt algorithms and features of SageMaker from <a href="https://www.linkedin.com/in/skrinak/"><strong>Kris Skrinak</strong> </a>during a boot camp roadshow for the Amazon Partners. Over the period, SageMaker has matured a lot to enable ML engineers to deploy and track models quickly and be scalable. Apart from its built-in Algorithms, there were many new features like AutoPilot, Model Clarify and Feature Store, Docker Container. This blog will look into these new SageMaker features and the ServerLess way of training, deployment, and real-time inference.</p><h3>Architecture</h3><p>The steps for the below reference architecture are explained at the end of the SageMaker Pipeline section of this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*vXBrABWoQJhkKL30WRMwsQ.png" /><figcaption>Real-Time Inference</figcaption></figure><h3>SageMaker Features</h3><h4>A) Auto Pilot-Low Code Machine Learning</h4><ul><li>Launched around DEC 2019</li><li>Industry-first Automated ML to give control and visibility to ML Models</li><li>Does Feature Processing, picks the best algorithm, trains and selects the best model with just a few clicks</li><li>Vertical AI services like Amazon Personalize and Amazon Forecast can be used for personalized recommendation and forecasting problems</li><li>AutoPilot is a generic ML service for all kinds of classification and regression problems like fraud detection and churn analysis and targeted marketing</li><li>Supports inbuilt Algorithms of SageMaker like xgboost and linear learner</li><li>Default max size of input dataset is 5 GB but can be increased in GBs only</li></ul><h4>Auto-Pilot Demo</h4><p><strong><em>Data for AutoPilot Experiment</em></strong></p><p>The dataset considered is public data provided by <a href="http://archive.ics.uci.edu/ml/machine-learning-databases/00603/"><strong>UCI</strong></a>.</p><p><strong><em>Data Set Information:</em></strong></p><p>The survey data describes different driving scenarios including the destination, current time, weather, passenger, etc., and then asks the person whether he will accept the coupon if he is the driver. The task we will be performing on this dataset is <em>Classification</em></p><p><strong><em>AutoPilot Experiment</em></strong></p><p>Import the data for training.</p><pre>%%sh<br>wget <a href="https://archive.ics.uci.edu/ml/machine-learning-databases/00603/in-vehicle-coupon-recommendation.csv">https://archive.ics.uci.edu/ml/machine-learning-databases/00603/in-vehicle-coupon-recommendation.csv</a></pre><p>Once data is uploaded, the AutoPilot can be set up within minutes using the SageMaker studio. Add the training input and output data paths, Label to predict and enable the auto-deployment of the model. SageMaker deploys the best model and creates an endpoint after the successful training.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*tOrotoJ5Y27_8gxvVv_hyw.png" /></figure><p>Alternately one can select the model of their wish and deploy it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*5zgD8Axus449_JpBvDySYA.png" /></figure><p>The endpoint configurations and endpoint details of deployed model can be found in the console</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*o30EbWNlwjZlp-jneV9G9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*Vdbj14bw1ofwxDZu_KwZhQ.png" /></figure><p><strong><em>Infer and Evaluate Model</em></strong></p><p>Take a validation record and invoke the endpoint. The feature engineering tasks are done by autopilot and thus raw features data can infer the trained model and predict.</p><pre>No Urgent Place,Friend(s),Sunny,80,10AM,Carry out &amp; Take away,2h,Female,21,Unmarried partner,1,Some college - no <br>degree,Unemployed,$37500 - $49999,,never,never,,4~8,1~3,1,1,0,0,1,1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*MVTrgPL13D7ukWmIAftotw.png" /></figure><p>Infer the model using validation data set using the code given in <a href="https://github.com/prasanth-m/sagemaker/blob/master/Auto-Pilot/infer.ipynb"><strong>Github</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*VXq-bfay22GpwjmrcfSTsw.png" /></figure><h4>B) SageMaker Clarify</h4><ul><li>Launched around DEC 2020</li><li>Explains how machine learning (ML) models made predictions during the Autopilot experiments</li><li>Monitors Bias Drift for Models in Production</li><li>Provides components that help AWS customers build less biased and more understandable machine learning models</li><li>Provides explanations for individual predictions available via API</li><li>Helps in establishing the model governance for ML applications</li></ul><p>The bias information can be generated for the AutoPilot experiment.</p><pre>bias_data_config = sagemaker.clarify.DataConfig(<br>    s3_data_input_path=training_data_s3_uri,<br>    s3_output_path=bias_report_1_output_path,<br>    label=&quot;Y&quot;,<br>    headers=train_cols,<br>    dataset_type=&quot;text/csv&quot;,<br>)</pre><pre>model_config = sagemaker.clarify.ModelConfig(<br>    model_name=model_name,<br>    instance_type=train_instance_type,<br>    instance_count=1,<br>    accept_type=&quot;text/csv&quot;,<br>)</pre><h4>C) SageMaker Feature Store</h4><ul><li>Launched around DEC 2020</li><li>Amazon SageMaker Feature Store is a fully managed repository to store, update, retrieve, and share machine learning (ML) features in S3.</li><li>The feature set that was used to train the model needs to be available to make real-time predictions (inference).</li><li>Data Wrangler of SageMaker Studio can be used to engineer features and ingest features into a feature store</li><li>Feature Store — both online and offline stores can be ingested via separate Featuring Engineering Pipeline via SDK</li><li>Streaming sources can directly ingest features to the online feature store for inference or feature creation</li><li>Feature Store automatically builds an Amazon Glue Data Catalog when Feature Groups are created and can optionally be turned off</li></ul><p>The below table shows various data stores used to maintain the features. Some open source frameworks like Feast have evolved as feature store platform and any key-value data store that supports fast lookup can be used as Feature Store.</p><p>The feature stores are end-stage of the feature engineering pipeline and the features can be stored in cloud Data Warehouses like Snowflake, RedShift too as shown in below image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*UPDb-VehKvLOFKehzPm2kQ.png" /><figcaption>Credit:<a href="https://www.featurestore.org/">https://www.featurestore.org/</a></figcaption></figure><pre>record_identifier_value = str(2990130)</pre><pre>featurestore_runtime.get_record(FeatureGroupName=transaction_feature_group_name, RecordIdentifierValueAsString=record_identifier_value)</pre><p>The feature group can be accessed as Hive external table too.</p><pre>CREATE EXTERNAL TABLE IF NOT EXISTS sagemaker_featurestore.coupon (<br>  write_time TIMESTAMP<br>  event_time TIMESTAMP<br>  is_deleted BOOLEAN<br>)<br>ROW FORMAT SERDE &#39;org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe&#39;<br>  STORED AS<br>  INPUTFORMAT &#39;parquet.hive.DeprecatedParquetInputFormat&#39;<br>  OUTPUTFORMAT &#39;parquet.hive.DeprecatedParquetOutputFormat&#39;<br>LOCATION &#39;s3://coupon-featurestore/onlinestore/139219451296/sagemaker/ap-south-1/offline-store/coupon-1621050755/data&#39;</pre><h4>D) SageMaker Pipelines</h4><ul><li>Launched around DEC 2020</li><li>SageMaker natively supports MLOPS via the SageMaker project and pipelines are created during the SageMaker Project creation</li><li>MLOPS is a standard to streamline the continuous delivery of models. It is essential for a successful production-grade ML application.</li><li>SageMaker pipeline is a series of interconnected steps that are defined by a JSON pipeline definition to perform build, train and deploy or only train and deploy etc.</li><li>The alternate ways to set up the MLOPS in SageMaker are Mlflow, Airflow and Kubeflow, Step Functions, etc.</li></ul><h3>Docker Containers</h3><p>SageMaker Studio itself runs from a Docker container. The docker containers can be used to migrate the existing on-premise live ML pipelines and models into the SageMaker environment.</p><p>Both stateful and stateless inference pipelines can be created. For example the anomaly and fraud detection pipelines are stateless and the example considered in this article is a stateful model inference pipeline.</p><p><strong>SageMaker Container Demo</strong></p><p>Download the <a href="https://github.com/prasanth-m/sagemaker/tree/master/container"><strong>Github </strong></a>folder. The container folder should show files as shown in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*xC5NLv77zrEd2ui_RnROyg.png" /></figure><p>The dataset is the same as we have considered for Autopilot Experiment.</p><p>The sckit-learn algorithm is used for the local training and model tuning. After various iterations, the features having less importance have been removed and then encoding has been performed for the key features.</p><p>The final encoded features (97 labels) are stored in coupon_train.csv and will be used for training and validation locally.</p><p><strong>Docker Container Build</strong></p><p>The following steps have to be performed in an orderly manner.</p><ol><li><em>Build the image</em></li></ol><pre>docker build -t recommend-in-vehicle-coupon:latest .</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*Yzd8qb3tCYI7WGdQ47H4Cw.png" /></figure><p>2. <em>Train the features in local mode</em></p><pre>./train_local.sh recommend-in-vehicle-coupon:latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*nnlRmQvDrfYf5b5sA0jYqQ.png" /></figure><p>3. <em>Serve the model in local mode</em></p><pre>./serve_local.sh recommend-in-vehicle-coupon:latest</pre><p>The servers are up and waiting for request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*aHJ_QFtddouh0YZfTKjpJQ.png" /></figure><p>4. <em>Predict locally</em></p><p>The payload.csv will have features to predict the model. Run below command to predict the response for the features available in the csv.</p><pre>./predict.sh payload.csv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*CzmhGOnbj3ICna6F5nu_6w.png" /></figure><p>Once the request is accepted, servers listening will respond to the requests received.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*wW8y5Kx0rU6_I2IqBrWg7A.png" /></figure><p>5. <em>Push Image</em></p><p>Once the local testing is completed, the container train, deploy and serve image can be pushed to AWS ECR. In case any code change is done, the final build and push step alone is enough.</p><pre>./build_and_push.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*6gvd9I7Qmg12hzMCPitQzQ.png" /></figure><p>Deployed Container Image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*indNmsld3nHbm2xGq2D3Ng.png" /></figure><p>The AWS ECR images can be pulled and containers can be run from Lambda, AWS EKS etc.</p><h3>Lambda Function</h3><p>The SageMaker API calls meant for training, deployment and inference are created as Lambda Functions. Then deployed Lambda handler function should be integrated with API Gateway so that pipeline can be run for any triggered API event.</p><p>The lambda function kept in <a href="https://github.com/prasanth-m/sagemaker/blob/master/Lambda/function.py"><strong>Github </strong></a>has three major blocks.</p><h4>Create SageMaker Training Function</h4><p>The lambda will read features from s3 and complete the training.</p><pre>client = boto3.client(&quot;sagemaker&quot;, region_name=region)<br>        client.create_training_job(**create_training_params) <br>        status = client.describe_training_job(TrainingJobName=job_name)[&quot;TrainingJobStatus&quot;]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*Asmdt4e82ztU4Ia4wzllzg.png" /></figure><h4>Create SageMaker Model and Endpoint Function</h4><p><strong>Create the model</strong></p><p>The training job will place model artifacts in s3 and that model has to be registered with SageMaker.</p><p>Register the models in the SageMaker environment using the below API call.</p><pre>create_model_response = client.create_model(<br>              ModelName=model_name, ExecutionRoleArn=role, PrimaryContainer=primary_container<br>              )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*0EJ0tcqJWZvRYVM2qYWzfg.png" /></figure><p><strong>Create End Point Config</strong></p><pre>response = client.create_endpoint_config(<br>            EndpointConfigName=endpoint_config_name,<br>            ProductionVariants=[<br>                {<br>                    &#39;VariantName&#39;: &#39;variant-1&#39;,<br>                    &#39;ModelName&#39;: model_name,<br>                    &#39;InitialInstanceCount&#39;: 1,<br>                    &#39;InstanceType&#39;: &#39;ml.t2.medium&#39;<br>                }<br>            ]<br>        )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*PodCyWfz5auA7Y6XHhosGw.png" /></figure><p><strong>Create End Point</strong></p><pre>response = client.create_endpoint(<br>            EndpointName=endpoint_name,<br>            EndpointConfigName=endpoint_config_name<br>        )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*65XmzgfRPg4apDWdZZq2Mg.png" /></figure><h4>Invoke SageMaker Model Function</h4><p>Based on the API request body message, the endpoint will be invoked by the Lambda.</p><pre>response = client.invoke_endpoint(<br>            EndpointName=EndpointName,<br>            Body=event_body.encode(&#39;utf-8&#39;),<br>            ContentType=&#39;text/csv&#39;<br>        )</pre><p>The status of the In-service endpoint and the requests made to the endpoint can be checked in the cloud watch logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*dyx6KJoNFsBdSDt1FgiIEw.png" /></figure><h3>Testing State-full Real-time Inference</h3><p><strong>Trigger SageMaker Training</strong></p><p>Once API Gateway and Lambda have been integrated, Training Job can be triggered by passing the below request body to Lambda function.</p><pre>{&quot;key&quot;:&quot;train_data&quot;}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*uQL5TAcKJ03KUulpnMSM0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*A3ZAUc932xmVIrN3N3-YrQ.png" /></figure><p><strong>Trigger SageMaker Model and Endpoint Deployment</strong></p><p>Once the training job is completed, deploy the model with the below request body. The training job should be the job which we created recently.</p><pre>{&quot;key&quot; : &quot;deploy_model&quot;,<br>&quot;training_job&quot; :&quot;&lt;training job name&gt;&quot;<br>}</pre><p><strong>Trigger SageMaker Model Endpoint</strong></p><p>Invoke the endpoint with the below request. The feature is encoded and should be the same as we used to train.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*2vq5T-04wPpIxzEyG9ueaw.png" /></figure><p>The predicted response will be as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*Nosro1Rr2fotQlpol4w2Fw.png" /></figure><p>The events created during invoking can be viewed in cloud watch logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*I0urAAgiR8d_e3R5N5yIXQ.png" /></figure><h3>Conclusion</h3><p>Machine Learning inference costs account for more than 80 percent of operational costs for running the ML workloads. The SageMaker capabilities like container orchestration, multi-model endpoint, serverless inference can save both operational and development costs. Also, the event-driven training and inference pipelines can enable any non-technical person from the sales or marketing team to refresh both batch and real-time predictions with a click of a button built using the mechanisms like API, webhooks from their sales portal on an Adhoc basis before running their campaign.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=789b43d33e4e" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/train-deploy-and-predict-cost-effective-ml-models-in-aws-cloud-789b43d33e4e">Train, Deploy and Predict Cost-Effective ML Models in AWS Cloud</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IoT/TimeSeries Event Processing using AWS Serverless Services & Managed Kafka Streaming]]></title>
            <link>https://aws.plainenglish.io/iot-timeseries-event-processing-using-aws-serverless-services-managed-kafka-streaming-f73979259a9e?source=rss-6248afeb5d6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f73979259a9e</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Prasanth Mathesh]]></dc:creator>
            <pubDate>Mon, 02 Aug 2021 08:18:12 GMT</pubDate>
            <atom:updated>2021-08-02T08:18:12.681Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In my previous <a href="https://medium.com/cloud-data-analytics/kappa-time-series-data-processing-overview-using-serverless-aws-services-535574125ea"><strong>article</strong></a>, AWS serverless design considerations were discussed for collecting and storing the TimeSeries events. The TimeSeries and IoT data share most of the characteristics except a few like the timestamp attribute. The time-series data arrival is predefined but IoT events can be in a random window. The IoT event analytics can be done either with IoT analytics or with Kafka but both have certain data processing limitations. The solution I have considered for this article has a mix of Kafka Streaming and IoT Analytics. The integration of AWS MSK with Kinesis Data Analytics or AWS Glue will be covered in detail in another article.</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*sVuYxQ1whscnIIcO-nIxmg.png" /></figure><p><strong>Why IoT Core?</strong></p><p>Kafka Protocol was built on top of TCP/IP whereas standard IoT devices support MQTT connections. MQTT was built considering bad network and communication. AWS IoT Core Device Gateway supports both HTTP and MQTT protocol, provides bi-directional communication with IoT devices and can filter and route data across the enterprise applications. It enables device registration in a simple manner thus accelerating IoT application development.</p><p><strong>Why AWS MSK?</strong></p><p>Apache Kafka is distributed messaging framework that provides fast, scalable and throughput ingestions. Kafka can replay IoT events, provides long-term storage, acts as a buffer when there is high-velocity data, provide easy integration with other enterprise applications. Real-time device monitoring is not possible in IoT Analytics whereas Kafka streaming along with an event processing framework can trigger actions for the anomalies in real-time.No downtime during Kafka cluster upgrade and clusters can be provisioned in 15 mins.Another main advantage is no charge for the data replication traffic across AZ and this is a key factor when compared with expensive highly available self-hosted Kafka clusters.</p><p><strong>Why IoT Analytics?</strong></p><p>AWS IoT Analytics can enrich the IoT data, perform ad-hoc analysis and build dashboards using QuickSight. It is a simple and serverless way to do data prep, clean and feature engineering and can be integrated with notebooks, AWS SageMaker to build machine learning models. Custom analysis code packaged in a container can also be executed on AWS IoT Analytics for use cases like understanding the performance of devices, predicting device failures, etc.</p><p><strong>Why TimeStream?</strong></p><p>Timestream can easily store and analyze trillions of events per day. The data retention can be controlled based on the analytics need. It has built-in time-series analytics functions, helping you identify trends and patterns in your data in near real-time. Timestream can provide 1000x faster query performance along with 1/10th the cost of relational databases. When the same record is received for a timestamp, timestream can deduplicate it which is a common problem with streaming events. When there is a high volume of ingestion, events need to be written into canonical datastore like kinesis and then it should be written to S3 for long-term storage.TimeStream can be serving datastore.</p><p><strong>Why AWS Lambda?</strong></p><p>The AWS Lambda can process data from an event source like Apache Kafka. The lambda is very cheap and its memory can be scaled from 128MB to 10240MB. Also, the processing timeout can be set for Lambda functions. The IoT device’s payload will be lesser in size and real-time device control operations based on incoming payload value can be easily done with AWS Lambda rather than using serverless services like AWS Glue or AWS Kinesis DataAnalytics. Lambda can be triggered by an event source like AWS MSK or it can be scheduled in AWS.</p><h3>Let’s Get Started</h3><p>The IoT device registration and IoT message simulation during development are critical tasks in IoT development and there is a need for the data engineering team to simulate the IoT events using various SaaS providers like MQTTLab, Cumulocity IoT etc.</p><p>The device registration and IoT Event data simulation for this article were done through the AWS IoT simulator. The simulator provides device type registrations, controlling the number of devices to simulate the data and to define payload structure for each device. The Automotive telemetry data was considered and simulated as shown in the steps below.</p><p><strong>Add Device Type</strong></p><p>Create a simulation stack in an AWS region and add custom devices. The automotive telemetry payload attributes are inbuilt and can’t be changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*abrL0hgiS5lH80IjoC-_rA.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WlxGq4Ks33Dgx-ioDeTTpg.gif" /><figcaption>Telemetry Data</figcaption></figure><p><strong>Simulate IoT Data</strong></p><p>Automotive Telemetry data is quite comprehensive and it can publish messages on three topics</p><p>Telemetry Topic Payload</p><pre>{<br>  &quot;name&quot;: &quot;speed&quot;,<br>  &quot;value&quot;: 47.4,<br>  &quot;vin&quot;: &quot;1NXBR32E84Z995078&quot;,<br>  &quot;trip_id&quot;: &quot;799fc110-fee2-43b2-a6ed-a504fa77931a&quot;,<br>  &quot;timestamp&quot;: &quot;2018-02-15 08:20:18.000000000&quot;<br>}</pre><p>Trip Topic Payload</p><pre>{&quot;vehicle_speed_mean&quot;:64.10065503146477,&quot;engine_speed_mean&quot;:3077.59476197646,&quot;torque_at_transmission_mean&quot;:210.70915084517395,&quot;oil_temp_mean&quot;:237.417022870719,&quot;accelerator_pedal_position_mean&quot;:28.819512721817887,&quot;brake_mean&quot;:4.268754736044446,&quot;high_speed_duration&quot;:0,&quot;high_acceleration_event&quot;:3,&quot;high_braking_event&quot;:0,&quot;idle_duration&quot;:75323,&quot;start_time&quot;:&quot;2021-03-06T07:40:02.454Z&quot;,&quot;ignition_status&quot;:&quot;run&quot;,&quot;brake_pedal_status&quot;:false,&quot;transmission_gear_position&quot;:&quot;fifth&quot;,&quot;odometer&quot;:35.27425650210172,&quot;fuel_level&quot;:97.7129231345363,&quot;fuel_consumed_since_restart&quot;:0.9155057461854811,&quot;latitude&quot;:38.938734,&quot;longitude&quot;:-77.269385,&quot;timestamp&quot;:&quot;2021-03-06 08:13:04.981000000&quot;,&quot;trip_id&quot;:&quot;c6bacef5-1bfc-4a72-8261-6c1272772f13&quot;,&quot;vin&quot;:&quot;5JO226H6QR3J3T7TI&quot;,&quot;name&quot;:&quot;aggregated_telemetrics&quot;}</pre><p>Diagnostics Topic Payload</p><pre>{&quot;timestamp&quot;:&quot;2021-03-06 08:14:33.087000000&quot;,&quot;trip_id&quot;:&quot;a4c55e6e-a7eb-4c3e-b0a0-dfcace119e03&quot;,&quot;vin&quot;:&quot;MQYK4Z8WGTJDFDA05&quot;,&quot;name&quot;:&quot;dtc&quot;,&quot;value&quot;:&quot;P0404&quot;}</pre><p>After completing the exercises, stop the simulation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*nwRocLalO3tKStfNjByIfw.png" /></figure><p>It is evident from the below image that the costs for IoT are cheap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cjTKFJSa5P6NPjrrWrSI-A.png" /></figure><h3>IoT Analytics</h3><p>IoT Analytics setup is a simple process and it can quickly create channel, pipeline and datastore etc. in a single click as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*DAhP0rfyat3avqtUeEPX_A.png" /></figure><p>The above setup was created to select all telemetry payloads from the subscribed topic.</p><p>The pipeline can be used to filter any unwanted attributes from the payload before creating a datastore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EzAXlSiwx8Ma2JzRrLXykg.png" /></figure><p>S3 is used as an underlying data store and the data format can be parquet or json.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*JGnRdv2IPhDznGyj2fFyng.png" /></figure><p><strong>Setup IoT Rule and Action</strong></p><p>Create a Rule and Action for the Telemetry Payload as given below. The objective is to select all records and ingest them into Telemetry Channel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*7T_CSFwn235VOUgSZCNmPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*5qsBhXBw81cqUneSzPO1vQ.png" /></figure><p>Once the simulation is started, the ingestion process can be monitored in the IoT Analytics window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*DtFje8wAsNd5fNaMVhg0fw.png" /></figure><p>The dataset can be created and scheduled to be refreshed from the datastore. The dataset can be refreshed from the last import timestamp using the delta time option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*l-vwlM70c4lBJmd7HD01rA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*m_6wbiUqUkyaPdANSH-lFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*lSFkmRnqVGea4g0pnhiL1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HyafxJlpAKFhPrSfpp82Lw.png" /></figure><p>The IoT Analytics dataset can be used in aws sagemaker notebooks and can be used as a data source for QuickSight.</p><h3>QuickSight</h3><p>Create a new IoT analytics data source using the telemetry_dataset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*5jJdU3cVpFsb1cbDoMM7wA.png" /></figure><p>Once the import is completed, the records can be enriched or filtered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4vq7BAQAhSJihqJe4osEYg.png" /></figure><p>The import process can be scheduled for auto-refresh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*SgJLnLLSyrxGMP9XG2LiHw.png" /></figure><p>The imported telemetry dataset values can be visualized in QuickSight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*j45Q3PVOySHLdSM1krqDXg.png" /></figure><h3>SageMaker</h3><p>Create a notebook and open the notebook using sagemaker instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7UByAon77q5rPB7UuDTCbg.png" /></figure><p>Import dataset and analyze the data for building machine learning models for predictive maintenance of devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*wf7k55HJul5JNjzqD8Cuyw.png" /></figure><p>A basic working version of SageMaker code is kept in <a href="https://github.com/prasanth-m/AWS/blob/master/IoT%20Analytics/telemetry.ipynb"><strong>Github</strong></a>. The feature engineering, model training and inference pipeline for near real-time data will be covered in a separate article in a detailed manner.</p><h3>TimeStream</h3><p>Pricing of timestream is 1 million writes of 1KB size = $0.50. Avg size of telemetry data is 145 bytes. Avg. size of aggregated trip data is 800 bytes. By merging all the dimensions like speed, fuel_level etc at the VIN level, we can reduce the number of writes per batch and cost. A detailed explanation about payload structure and batching the writes have been explained in my previous <a href="https://medium.com/cloud-data-analytics/collect-and-store-streaming-timeseries-data-into-amazon-timestream-db-6178bee7434a"><strong>article</strong></a>. Create a Rule and Action for Timestream if the data is aggregated at the source itself or process IoT events stored in MSK using the Kinesis Data Analytics for Flink or using a custom apache-spark application.</p><h3>AWS MSK</h3><p>AWS MSK was recently introduced as one of the Actions for IoT Core. IoT Rule Action can act as producer for Managed Streaming Kafka and can act for the rule defined. Create a VPC destination and add the cluster details and authentication mechanisms of the Kafka cluster to receive the messages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*pYzhNWdw2iXEP-sMlx46tg.png" /></figure><p>Enable error logging for action</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*4_7VwiuYoE95K4VY8RmPlg.png" /></figure><p>Enable CloudWatch Logs and cloud trail for IoT and AWS MSK to analyze the log and API calls.</p><h3>Lambda</h3><p>Create a lambda function to consume and process the data.</p><pre>for  partition in partitions:                         consumer.seek_to_beginning(partition) #sample read. use offset</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FPgW4u-yABk8GQWN7J3Viw.png" /></figure><p>The diagnostic data is less in volume but needs immediate action. The lambda will consume, check for a problem code and issue STOP signal to the device by publishing a payload to MQTT topic meant for a shadow device.</p><pre>response = IOTCLIENT.publish(topic=iottopic, qos=0, payload=json.dumps(msg))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*oNJali1P7DAR8Uwx8JM0pA.png" /></figure><p>The working version of the lambda function is kept in Github <a href="https://github.com/prasanth-m/AWS/blob/master/IoT%20Analytics/kafk_consumer.py"><strong>kafka_consumer.py</strong></a></p><h3>Conclusion</h3><p>IoT data can be processed and stored by various AWS services based on the use cases. The serverless AWS services can aid the rapid development of large-scale complicated architecture in an easily scalable manner. The managed services like AWS MSK and a choice of distributed data processing frameworks like Apache Flink-based Kinesis data analytics or Apache Spark-based AWS Glue will help in building scalable highly available and cost-effective processing for IoT/TimeSeries events. The AWS MSK will enable organisations to migrate the on-premise Kafka workloads into the cloud and also can support &gt; 1 MB/Sec writes which is not possible in kinesis.</p><p><em>Originally published at </em><a href="https://medium.com/cloud-data-analytics/iot-timeseries-event-processing-using-aws-serverless-services-and-aws-managed-kafka-streaming-af12fdd0699a?source=user_profile---------0----------------------------"><em>https://medium.com</em></a><em> on July 24, 2021.</em></p><p><em>More content at </em><a href="http://plainenglish.io/"><strong><em>plainenglish.io</em></strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f73979259a9e" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/iot-timeseries-event-processing-using-aws-serverless-services-managed-kafka-streaming-f73979259a9e">IoT/TimeSeries Event Processing using AWS Serverless Services &amp; Managed Kafka Streaming</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SnowPark -The Scala developer experience on Snowflake Data Cloud]]></title>
            <link>https://medium.com/cloud-data-analytics/snowpark-the-scala-developer-experience-for-snowflake-data-cloud-b4d7ee070e56?source=rss-6248afeb5d6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4d7ee070e56</guid>
            <category><![CDATA[scala]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Prasanth Mathesh]]></dc:creator>
            <pubDate>Sun, 27 Jun 2021 07:52:39 GMT</pubDate>
            <atom:updated>2023-09-01T01:27:10.005Z</atom:updated>
            <content:encoded><![CDATA[<p>Running scala code UDFs at scale inside the Snowflake data Cloud</p><h3>Overview</h3><p>Last year snowflake has announced a lot of features like support for unstructured data, snowtire, snowpark , snowsight etc. In this, one of the anticipated features SnowPark is now available for preview. Until recent time, the Snowflake doesn&#39;t have native integration with ML applications and also the support for having a data quality framework at the extraction/ingestion phase. The CI/CD for data pipelines, Data Quality, lineage at the attribute level was quite tricky and had to depend on other vendor services. The SnowPark Scala API feature has opened the gate to address these features.</p><h3>SnowPark</h3><p>The following are some of the key features supported by SnowPark as of today.</p><ul><li>Execution of Snowflake SQLs via programming.</li><li>Lazy analysis on the server reduces the amount of data transferred between your client and the Snowflake database.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*qwAOdmB4dNbRqy_55LUXcA.png" /></figure><ul><li>UDFs created at the client end can be pushed into the server and run on the server.</li><li>The custom ML models can be trained in other languages like Python and those models can be exported as a jar and can be invoked.</li></ul><p>The <strong>Scala </strong>code used in this article is kept in <a href="https://github.com/prasanth-m/snowflake/tree/main/SnowPark/src/main/scala"><strong>Github</strong></a>. Though SnowPark is at a nascent stage of development, let&#39;s see some of its current features.</p><p><strong>Create Session</strong></p><p>Create a session and select a table.</p><pre><strong>val </strong>session = Session.<em>builder</em>.configs(configMap).create<br><strong>val </strong>df = session.sql( query = &quot;select * from region&quot;)<br>df.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fPSw6vw6oL6KPBO1jHZAeQ.png" /></figure><h4>Join</h4><p>Create two tables in Snowflake and join them and save the result in another table.</p><pre><strong>val </strong>reg = session.sql( query = &quot;select * from region&quot;)<br><strong>val </strong>nat = session.sql( query = &quot;select * from nation&quot;)<br><strong>val </strong>joined_df = reg.join(nat,reg(&quot;R_REGIONKEY&quot;) ===  nat(&quot;N_REGIONKEY&quot;),&quot;inner&quot;)<br>joined_df.show()<br>joined_df.write.mode(Overwrite).saveAsTable(&quot;joined_df&quot;)</pre><p>Joined Result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D2rUberC2p667usE8Wr3-Q.png" /></figure><p>The below is the snowflake SQL created by the server for the above operation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*gF4Z2p88HEli5bEdCx9jsw.png" /></figure><p>The final created table in snowflake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9IpW1UteiE4IlZT4azi6_w.png" /></figure><h4>Read JSON API</h4><p>The web apps can natively write data into a snowflake and this will change the way data pipelines are built. The NY city supports open API and let&#39;s read it as JSON.</p><p>Read a JSON and create a data frame</p><pre><strong>def </strong>getJsonData =  {<br>  <strong>val </strong>url = &quot;https://data.cityofnewyork.us/resource/2npr-yv2b.json&quot;<br>  scala.io.Source.<em>fromURL</em>(url).mkString<br>}<br><br><strong>val </strong>df = session.createDataFrame(<em>Seq</em>(getJsonData))<br>df.show()</pre><p>Once JSON is read and all cleansing/processing is done, the data frame can be merged/inserted into a table or it can be moved into the internal stage of the snowflake. The below is the stage created for storing the json.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*dZ4-K-H6otqRXs-L2fMTug.png" /></figure><p>Once uploaded, list the files via session API.</p><pre>session.sql(s&quot;ls @<strong>$</strong>dataStageName&quot;).show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BsA8FusBzAyXCF4uSBJJ3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J4F6XjXrrCjcjTCrIqaoVg.png" /></figure><h4>File Put</h4><p>The dependency Jars and exported custom jar models can be placed into the internal and can be used for UDF operations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*g1HPagjYuK82LnCr8fu10Q.png" /></figure><h3>Conclusion</h3><p>The snowpark Scala API paves way for limitless possibilities such as enabling the organization to bring in their own solutions built for a specific purpose into snowflake data pipelines without much rework or development effort. Additionally, adoption of custom-built java/scala based data quality frameworks, the ML inferences (can save almost 80 per cent costs) and sharing the ML predictions in a real-time manner can be seen in the snowflake data platform.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4d7ee070e56" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloud-data-analytics/snowpark-the-scala-developer-experience-for-snowflake-data-cloud-b4d7ee070e56">SnowPark -The Scala developer experience on Snowflake Data Cloud</a> was originally published in <a href="https://medium.com/cloud-data-analytics">Cloud Data and Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud-Native integration between Snowflake on AWS and Databricks on GCP]]></title>
            <link>https://medium.com/cloud-data-analytics/cloud-native-integration-between-databricks-and-snowflake-on-gcp-a32fd89884db?source=rss-6248afeb5d6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a32fd89884db</guid>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Prasanth Mathesh]]></dc:creator>
            <pubDate>Mon, 21 Jun 2021 09:59:28 GMT</pubDate>
            <atom:updated>2021-06-24T05:08:06.575Z</atom:updated>
            <content:encoded><![CDATA[<p>Enable data transfers between cloud storage services using vendor-neutral platforms</p><h3>Introduction</h3><p>The organizations that maintain multi-cloud often end up sharing data between their cloud storage accounts. There are various reasons and methodologies for the data transfers and here we are going to see how we can set up an integration between snowflake and databricks using GCS as a storage layer without the need of orchestration tool or serverless functions to monitor the data transfers in a quick and seamless way.</p><h3>Databricks</h3><p>Databricks was recently launched on the GCP marketplace platform and once a workspace is created (hosted in GCP Europe-west2 ), Databricks itself creates GCS for its internal use with necessary role and permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*WjCW4_JSwJzZ2Ds67n1moA.png" /></figure><h3><strong>Snowflake</strong></h3><p>In a snowflake environment (hosted in the AWS ), create a storage integration for the GCS.</p><pre>create storage integration gcs_databricks<br>  type = external_stage<br>  storage_provider = gcs<br>  enabled = true<br>  storage_allowed_locations = (&#39;gcs://databricks-7725329731828953/&#39;)<br> ;</pre><p>Create a stage for the GCS integration</p><pre>create stage aws_gcp_databricks<br>  storage_integration =  gcs_databricks<br>  url = &#39;gcs://databricks-7725329731828953/&#39;<br>  ;</pre><p>If we list the files in the bucket and it will throw a permission error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*lpx7Q8Pu2RP9NIZEgt_xjw.png" /></figure><p>Create a new role with necessary permissions or add an account to an existing role that has permissions to storage. The role created for databricks service will have permissions and I have added the snowflake service account as an additional member.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*1gK50hYc7kE672ix0I8kvw.png" /></figure><p>Upload a file to bucket and list it in snowflake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*AObHm2PMu2XD7gO_HtBglw.png" /></figure><p>The jobs/tasks can be scheduled in databricks / snowflake environment to unload data into GCS or to copy from the GCS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*w8z5RkNqUDMMNiS7h8fESg.png" /></figure><p>Let&#39;s do a transfer from snowflake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6bvqXJTqOGDCI_B8uluieA.png" /></figure><p>List files in GCS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*1k6dtPeRxFT0uzhl7GlMYg.png" /></figure><p>The files landing in the S3 data lake can be sent to GCS/datalake with minimal transformations or as is using SQL commands without loading into Datawarehouse. This is one of the basics of lakehouse architecture.</p><p>I have kept the movie lens dataset in S3. The snowflake stage is the same we have seen in this <a href="https://medium.com/cloud-data-analytics/implementing-pattern-recognition-for-time-series-data-in-snowflake-28e781765429?source=---------5----------------------------"><strong>article</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*ApKACHqv5AXoDOBjJz4EPQ.png" /></figure><p>The below SQL reads data from S3 stage and composes a JSON Object</p><pre>with temp as<br>(<br>select $1 as userid,$3 rating,count($3) as rating_count<br>from <a href="http://twitter.com/hist_parquet/test">@hist_parquet/test</a>/ratings.csv (file_format =&gt; csv_plain) t<br>where $3 = &#39;4.0&#39;<br>group by $1,$3<br>)<br>select object_construct (<br>*<br>)<br>from temp<br>;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*ftdI2h5AKe96obX_VUXllQ.png" /></figure><p>The same SQL is used in copy into command.</p><pre>copy into &#39;<a href="http://twitter.com/aws_gcp_databricks/rating_payload">@aws_gcp_databricks/rating</a>&#39; from<br>  (<br> with temp as<br> (<br> select $1 as userid,$3 rating,count($3) as rating_count<br> from <a href="http://twitter.com/hist_parquet/test">@hist_parquet/test</a>/ratings.csv (file_format =&gt; csv_plain) t<br> where $3 = &#39;4.0&#39;<br> group by $1,$3<br> )<br> select object_construct (<br>  *<br>  )<br> from temp<br>) file_format = (format_name = &#39;json_plain&#39;)<br>;</pre><p>The data has been pushed to GCS upon execution of the copy command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*Xs-xYV6W6kE6YqJPRlks9A.png" /></figure><p>Instead of polling, create the notifications for google cloud PUB/SUB for the object changes in GCS</p><pre>gsutil notification create -t recommend-input -f json gs://databricks-7725329731828953/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Aut0aaETL2voAIrZbB0tfQ.png" /></figure><p>After enabling the subscriptions and pull can be performed in Google PUB/SUB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*sMSW01lqh_XuhPn5ZqHjNA.png" /></figure><p>Databricks has its own file system DBFS and let&#39;s upload a file in /FileStore</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*QczenoAJ3X9Pj6VZvuKScg.png" /></figure><p>The uploaded file can be accessed from snowflake using the GCS stage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*u_NxWIkbbiwsHEIVO_prag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*B4X4FsWI0RjnY7ohBF9Exw.png" /></figure><h3><strong>Conclusion</strong></h3><p>The integration between SAAS/PAAS created in the cloud platforms like AWS GCP AZURE can be done in a seamless manner via API commands without any orchestration/ETL tools. Also, the data can be consumed in a near-realtime manner between these two platforms since they have high bandwidth data pipe with GCS for their respective service accounts. Additionally, the decoupled storage architecture enables storage of the raw/processed data in a single place or with a cheaper storage provider and also avoids the need to have additional data transfer services.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a32fd89884db" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloud-data-analytics/cloud-native-integration-between-databricks-and-snowflake-on-gcp-a32fd89884db">Cloud-Native integration between Snowflake on AWS and Databricks on GCP</a> was originally published in <a href="https://medium.com/cloud-data-analytics">Cloud Data and Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing a Movie Recommendation pipeline using Databricks on Google cloud]]></title>
            <link>https://medium.com/cloud-data-analytics/implementing-cloud-native-data-processing-pipelines-using-databricks-in-google-cloud-fc13e6155159?source=rss-6248afeb5d6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc13e6155159</guid>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Prasanth Mathesh]]></dc:creator>
            <pubDate>Mon, 21 Jun 2021 02:33:32 GMT</pubDate>
            <atom:updated>2025-03-05T23:49:23.426Z</atom:updated>
            <content:encoded><![CDATA[<p>Cloud-Native ML and Data Stacks avoid the vendor lock-in</p><h3>Basics</h3><h4>Cloud-Native</h4><p>Cloud-native technologies like containers, microservices, declarative APIs etc empower organizations to build and run scalable applications in cloud environments.</p><h4>CNCF</h4><p>Cloud-Native Computing Foundation (CNCF) serves as the vendor-neutral home for many of the fastest-growing open-source projects, including Kubernetes, Prometheus, and Envoy.</p><h4>Kubernetes</h4><p>Kubernetes is an open-source container-orchestration system for automating computer application deployment, scaling, and management. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation.</p><h4>Databricks on GCP</h4><p>Databricks on Google Cloud supports containerized deployments of Databricks in the cloud featuring tight integrations with Google Cloud’s big data and analytics services.</p><h4>Recommendation Algorithms</h4><p>The Collaborative filtering technique was widely adopted by e-commerce, movie streaming etc platforms. It basically identifies the similarities in historical events and recommends an item/content for users.</p><p>Apart from this, there are algorithms like popularity based, content based, matrix factorization.</p><p>But widely adopted recommendation algorithms come as low code package like surprise <a href="http://surpriselib.com/"><strong>http://surpriselib.com/</strong></a></p><p>Spark Mllib supports a matrix factorization algorithm that uses Alternating Least Squares (ALS) technique</p><h3>Let’s get started</h3><p>In the previous <a href="https://medium.com/cloud-data-analytics/cloud-native-integration-between-databricks-and-snowflake-on-gcp-a32fd89884db?source=---------0----------------------------"><strong>article</strong></a>, we have seen how to transfer data between snowflake and databricks.</p><p>The same rating payload is used for the recommendation experiment mentioned below. The Scala code used in the article is kept in <a href="https://github.com/prasanth-m/GCP/blob/master/Recommendation%20Engine/rating.scala"><strong>Github</strong></a>.</p><pre>val temp=spark.read.schema(rating_schema).json(&quot;dbfs:/tmp/ratings_data_019d2243_0000_1534_0000_00010cbef1ed_0_0_0_json.gz&quot;).persist()</pre><p>Split the dataset</p><pre>val Array(training, test) = ratings.randomSplit(Array(0.8, 0.2))</pre><p>Build Model</p><pre>// Build the recommendation model using ALS on the training data<br>import org.apache.spark.ml.evaluation.RegressionEvaluator<br>import org.apache.spark.ml.recommendation.ALS</pre><pre>val als = new ALS().setMaxIter(5).setRegParam(0.01).setUserCol(&quot;USERID&quot;)      <br>  .setItemCol(&quot;MOVIEID&quot;)<br>  .setRatingCol(&quot;RATING&quot;)<br>val model = als.fit(training)</pre><p>After evaluation, generate the results</p><pre>// Generate top 10 movie recommendations for each user<br>val userRecs = model.recommendForAllUsers(10)<br>//val userSubsetRecs = model.recommendForUserSubset(userRecs, 10)</pre><pre>// Generate top 10 user recommendations for each movie<br>val movieRecs = model.recommendForAllItems(10)<br>//val movieSubSetRecs  = model.recommendForUserSubset(movieRecs, 10)<br>userRecs.show(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*4Oww1GuwobmGCUnjCgMWJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*EyKK7kng6-JtWqw2BPfHHg.png" /></figure><p>The recommended movies for users can be stored as a table Databricks Feature Store and then results can be served online.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc13e6155159" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloud-data-analytics/implementing-cloud-native-data-processing-pipelines-using-databricks-in-google-cloud-fc13e6155159">Implementing a Movie Recommendation pipeline using Databricks on Google cloud</a> was originally published in <a href="https://medium.com/cloud-data-analytics">Cloud Data and Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>